Skip to content

Commit

Permalink
add test fluid
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPlacentino committed Jan 2, 2023
1 parent 77de162 commit 615ccb2
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/obsilab/mcsc/MCSC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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?

}
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/obsilab/mcsc/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<LiquidBlock> TEST_FLUID_BLOCK = BLOCKS.register("test_fluid_block",
() -> new LiquidBlock(
ModFluids.SOURCE_TEST_FLUID,
BlockBehaviour.Properties
.copy(Blocks.WATER)
));

public static final RegistryObject<Block> CRYSTAL_INGOT_BLOCK = BLOCKS.register( // crop block, so not register BlockItem
"crystal_ingot",
() -> new CrystalIngotBlock(BlockBehaviour.Properties
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/obsilab/mcsc/fluid/BaseFluidType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -32,7 +33,7 @@ public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
public ResourceLocation getStillTexture() {
return stillTexture;
}

// TODO other textures
// @Nullable for the getOverlayTexture override, if used
// @NotNull for the modifyFogColor override, if used

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/obsilab/mcsc/fluid/ModFluidTypes.java
Original file line number Diff line number Diff line change
@@ -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<FluidType> FLUID_TYPES =
DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, MCSC.MOD_ID);

public static final RegistryObject<FluidType> TEST_FLUID_TYPE =
register("test_fluid", FluidType.Properties.create()
.viscosity(1)
.canConvertToSource(false)
.fallDistanceModifier(1f)
// try out other properties
);

private static RegistryObject<FluidType> 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);
}

}
35 changes: 34 additions & 1 deletion src/main/java/com/obsilab/mcsc/fluid/ModFluids.java
Original file line number Diff line number Diff line change
@@ -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<Fluid> FLUIDS =
DeferredRegister.create(ForgeRegistries.FLUIDS, MCSC.MOD_ID);

public static final RegistryObject<FlowingFluid> SOURCE_TEST_FLUID =
FLUIDS.register("test_fluid", () -> new ForgeFlowingFluid.Source(ModFluids.TEST_FLUID_PROPERTIES));

public static final RegistryObject<FlowingFluid> 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);
}
}
5 changes: 0 additions & 5 deletions src/main/java/com/obsilab/mcsc/fluid/ModFluidsTypes.java

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/java/com/obsilab/mcsc/item/ModItems.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -94,6 +97,24 @@ public class ModItems {
//.tab(ModCreativeModeTab.MCSC_TAB)
));

public static final RegistryObject<Item> 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<Item> 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<Item> TEST_ITEM_ITEM = ITEMS.register(
"test_item", () -> new TestItem(
// new Item.Properties()
Expand All @@ -103,6 +124,16 @@ public class ModItems {
//.tab(ModCreativeModeTab.MCSC_TAB)
));

public static final RegistryObject<Item> 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);
}
Expand Down

0 comments on commit 615ccb2

Please # to comment.