From 615ccb2c3225c0290a1a254ccfbe80c6ef58c431 Mon Sep 17 00:00:00 2001 From: ticccco <23436953+LucasPlacentino@users.noreply.github.com> Date: Mon, 2 Jan 2023 14:58:05 +0100 Subject: [PATCH] add test fluid --- src/main/java/com/obsilab/mcsc/MCSC.java | 8 +++++ .../com/obsilab/mcsc/block/ModBlocks.java | 10 ++++++ .../com/obsilab/mcsc/fluid/BaseFluidType.java | 5 +-- .../com/obsilab/mcsc/fluid/ModFluidTypes.java | 34 ++++++++++++++++++ .../com/obsilab/mcsc/fluid/ModFluids.java | 35 ++++++++++++++++++- .../obsilab/mcsc/fluid/ModFluidsTypes.java | 5 --- .../java/com/obsilab/mcsc/item/ModItems.java | 31 ++++++++++++++++ 7 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/obsilab/mcsc/fluid/ModFluidTypes.java delete mode 100644 src/main/java/com/obsilab/mcsc/fluid/ModFluidsTypes.java diff --git a/src/main/java/com/obsilab/mcsc/MCSC.java b/src/main/java/com/obsilab/mcsc/MCSC.java index b97643b..e72937c 100644 --- a/src/main/java/com/obsilab/mcsc/MCSC.java +++ b/src/main/java/com/obsilab/mcsc/MCSC.java @@ -4,6 +4,8 @@ import com.obsilab.mcsc.block.ModBlocks; import com.obsilab.mcsc.block.custom.CrystalIngotBlock; import com.obsilab.mcsc.event.CreativeTabEvents; +import com.obsilab.mcsc.fluid.ModFluidTypes; +import com.obsilab.mcsc.fluid.ModFluids; import com.obsilab.mcsc.item.ModItems; import com.obsilab.mcsc.networking.ModMessages; import com.obsilab.mcsc.world.feature.ModConfiguredFeatures; @@ -96,6 +98,10 @@ public MCSC() //ModFeatures.register(modEventBus); // registers features + //ModFluids before ModFluidTypes? + ModFluids.register(modEventBus); // registers fluids + ModFluidTypes.register(modEventBus); // registers fluid types + // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); @@ -203,6 +209,8 @@ public static void onClientSetup(FMLClientSetupEvent event) LOGGER.info("HELLO FROM CLIENT SETUP"); LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); + //set render layer for fluid? in json? + } } } diff --git a/src/main/java/com/obsilab/mcsc/block/ModBlocks.java b/src/main/java/com/obsilab/mcsc/block/ModBlocks.java index d14dc12..b132462 100644 --- a/src/main/java/com/obsilab/mcsc/block/ModBlocks.java +++ b/src/main/java/com/obsilab/mcsc/block/ModBlocks.java @@ -3,6 +3,7 @@ import com.obsilab.mcsc.MCSC; import com.obsilab.mcsc.block.custom.CrystalIngotBlock; import com.obsilab.mcsc.block.custom.TestBlock; +import com.obsilab.mcsc.fluid.ModFluids; import com.obsilab.mcsc.item.ModItems; import com.obsilab.mcsc.item.custom.TestItem; import net.minecraft.util.valueproviders.UniformInt; @@ -12,6 +13,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DropExperienceBlock; +import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraftforge.eventbus.api.IEventBus; @@ -60,6 +62,14 @@ public class ModBlocks { .strength(6f) .lightLevel(state -> state.getValue(TestBlock.ACTIVE) ? 8 : 0) // light level of 8 if block's ACTIVE property is true, else light level of 0 )); + + public static final RegistryObject TEST_FLUID_BLOCK = BLOCKS.register("test_fluid_block", + () -> new LiquidBlock( + ModFluids.SOURCE_TEST_FLUID, + BlockBehaviour.Properties + .copy(Blocks.WATER) + )); + public static final RegistryObject CRYSTAL_INGOT_BLOCK = BLOCKS.register( // crop block, so not register BlockItem "crystal_ingot", () -> new CrystalIngotBlock(BlockBehaviour.Properties diff --git a/src/main/java/com/obsilab/mcsc/fluid/BaseFluidType.java b/src/main/java/com/obsilab/mcsc/fluid/BaseFluidType.java index b7a426a..ddd330f 100644 --- a/src/main/java/com/obsilab/mcsc/fluid/BaseFluidType.java +++ b/src/main/java/com/obsilab/mcsc/fluid/BaseFluidType.java @@ -15,12 +15,13 @@ public class BaseFluidType extends FluidType { //private final Vector3f fogColor; // fog when inside the fluid //contructor: - public BaseFluidType(final ResourceLocation stillTexture, final Properties properties) { + public BaseFluidType(final ResourceLocation stillTexture, final Properties properties) { //TODO add other textures in arguments super(properties); this.stillTexture = stillTexture; } //getter(s): + // TODO other textures public ResourceLocation getStillTexture() { return stillTexture; } @@ -32,7 +33,7 @@ public void initializeClient(Consumer consumer) { public ResourceLocation getStillTexture() { return stillTexture; } - + // TODO other textures // @Nullable for the getOverlayTexture override, if used // @NotNull for the modifyFogColor override, if used diff --git a/src/main/java/com/obsilab/mcsc/fluid/ModFluidTypes.java b/src/main/java/com/obsilab/mcsc/fluid/ModFluidTypes.java new file mode 100644 index 0000000..8be2b9b --- /dev/null +++ b/src/main/java/com/obsilab/mcsc/fluid/ModFluidTypes.java @@ -0,0 +1,34 @@ +package com.obsilab.mcsc.fluid; + +import com.obsilab.mcsc.MCSC; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fluids.FluidType; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModFluidTypes { // liquid, gas, plasma ? + + public static final ResourceLocation TEST_FLUID_STILL_RL = new ResourceLocation("block/test_fluid_still"); + + public static final DeferredRegister FLUID_TYPES = + DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, MCSC.MOD_ID); + + public static final RegistryObject TEST_FLUID_TYPE = + register("test_fluid", FluidType.Properties.create() + .viscosity(1) + .canConvertToSource(false) + .fallDistanceModifier(1f) + // try out other properties + ); + + private static RegistryObject register(String name, FluidType.Properties properties) { + return FLUID_TYPES.register(name, () -> new BaseFluidType(TEST_FLUID_STILL_RL, properties)); + } + + public static void register(IEventBus eventBus) { + FLUID_TYPES.register(eventBus); + } + +} diff --git a/src/main/java/com/obsilab/mcsc/fluid/ModFluids.java b/src/main/java/com/obsilab/mcsc/fluid/ModFluids.java index eaa8ebf..33e0fd6 100644 --- a/src/main/java/com/obsilab/mcsc/fluid/ModFluids.java +++ b/src/main/java/com/obsilab/mcsc/fluid/ModFluids.java @@ -1,8 +1,41 @@ package com.obsilab.mcsc.fluid; +import com.obsilab.mcsc.MCSC; +import com.obsilab.mcsc.block.ModBlocks; +import com.obsilab.mcsc.item.ModItems; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; +// TODO // fluids: NF3 gas (Nitrogen Trifluoride) for dry (plasma) etching, Nitrogen gas for internal FOUP atmosphere ... public class ModFluids { - //TODO + public static final DeferredRegister FLUIDS = + DeferredRegister.create(ForgeRegistries.FLUIDS, MCSC.MOD_ID); + + public static final RegistryObject SOURCE_TEST_FLUID = + FLUIDS.register("test_fluid", () -> new ForgeFlowingFluid.Source(ModFluids.TEST_FLUID_PROPERTIES)); + + public static final RegistryObject FLOWING_TEST_FLUID = + FLUIDS.register("flowing_test_fluid", () -> new ForgeFlowingFluid.Flowing(ModFluids.TEST_FLUID_PROPERTIES)); + + public static final ForgeFlowingFluid.Properties TEST_FLUID_PROPERTIES = + new ForgeFlowingFluid.Properties( + ModFluidTypes.TEST_FLUID_TYPE, + SOURCE_TEST_FLUID, + FLOWING_TEST_FLUID) + .slopeFindDistance(2) + .levelDecreasePerBlock(2) + .block(ModBlocks.TEST_FLUID_BLOCK) + .bucket(ModItems.TEST_FLUID_BUCKET) + ; + + public static void register(IEventBus eventBus) { + FLUIDS.register(eventBus); + } } diff --git a/src/main/java/com/obsilab/mcsc/fluid/ModFluidsTypes.java b/src/main/java/com/obsilab/mcsc/fluid/ModFluidsTypes.java deleted file mode 100644 index 644c9ab..0000000 --- a/src/main/java/com/obsilab/mcsc/fluid/ModFluidsTypes.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.obsilab.mcsc.fluid; - -public class ModFluidsTypes { // liquid, gas, plasma ? - //TODO -} diff --git a/src/main/java/com/obsilab/mcsc/item/ModItems.java b/src/main/java/com/obsilab/mcsc/item/ModItems.java index 33f6d55..5681d44 100644 --- a/src/main/java/com/obsilab/mcsc/item/ModItems.java +++ b/src/main/java/com/obsilab/mcsc/item/ModItems.java @@ -1,8 +1,11 @@ package com.obsilab.mcsc.item; import com.obsilab.mcsc.MCSC; +import com.obsilab.mcsc.fluid.ModFluids; import com.obsilab.mcsc.item.custom.TestItem; +import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -94,6 +97,24 @@ public class ModItems { //.tab(ModCreativeModeTab.MCSC_TAB) )); + public static final RegistryObject WRENCH_ITEM = ITEMS.register( + "wrench", () -> new Item( + new Item.Properties() + .stacksTo(1) + .durability(100) + //.group(MCSC.MCSC_GROUP) + //.tab(ModCreativeModeTab.MCSC_TAB) + )); + + public static final RegistryObject TOOLKIT_ITEM = ITEMS.register( + "toolkit", () -> new Item( + new Item.Properties() + .stacksTo(1) + .durability(100) + //.group(MCSC.MCSC_GROUP) + //.tab(ModCreativeModeTab.MCSC_TAB) + )); + public static final RegistryObject TEST_ITEM_ITEM = ITEMS.register( "test_item", () -> new TestItem( // new Item.Properties() @@ -103,6 +124,16 @@ public class ModItems { //.tab(ModCreativeModeTab.MCSC_TAB) )); + public static final RegistryObject TEST_FLUID_BUCKET = ITEMS.register( + "test_fluid_bucket", () -> new BucketItem( + ModFluids.SOURCE_TEST_FLUID, + new Item.Properties() + .craftRemainder(Items.BUCKET) + .stacksTo(1) + //.group(MCSC.MCSC_GROUP) + //.tab(ModCreativeModeTab.MCSC_TAB) + )); + public static void register(IEventBus eventBus) { ITEMS.register(eventBus); }