From eae496566bab9c3f775786177617447fa81a4a7a Mon Sep 17 00:00:00 2001 From: eerussianguy Date: Tue, 1 Oct 2024 21:56:01 -0400 Subject: [PATCH] - Buff rennet drops - Add config for classic sprinkler behavior - Disallow knapping with rotten pumpkins --- resources/data.py | 2 +- resources/recipes.py | 2 +- .../HydroponicPlanterBlockEntity.java | 2 +- .../blockentities/SprinklerBlockEntity.java | 33 +++++++++++++++++-- .../firmalife/common/items/SprinklerItem.java | 3 +- .../firmalife/config/FLServerConfig.java | 2 ++ .../data/firmalife/loot_modifiers/rennet.json | 2 +- .../loot_modifiers/rennet_three.json | 2 +- .../firmalife/tfc/knapping_types/pumpkin.json | 5 ++- 9 files changed, 44 insertions(+), 9 deletions(-) diff --git a/resources/data.py b/resources/data.py index 723eb8ef..26fc328f 100644 --- a/resources/data.py +++ b/resources/data.py @@ -204,7 +204,7 @@ def generate(rm: ResourceManager): ### MISC DATA ### global_loot_modifiers(rm, 'firmalife:fruit_leaf', 'firmalife:rennet', 'firmalife:rennet_three', 'firmalife:ice_shavings') - global_loot_modifier(rm, 'rennet', 'firmalife:add_item', {'item': item_stack_codec('4 firmalife:rennet')}, match_entity_tag('firmalife:drops_rennet')) + global_loot_modifier(rm, 'rennet', 'firmalife:add_item', {'item': item_stack-_codec('4 firmalife:rennet')}, match_entity_tag('firmalife:drops_rennet')) global_loot_modifier(rm, 'rennet_three', 'firmalife:add_item', {'item': item_stack_codec('6 firmalife:rennet')}, match_entity_tag('firmalife:drops_three_rennet')) global_loot_modifier(rm, 'fruit_leaf', 'firmalife:add_item', {'item': item_stack_codec('firmalife:fruit_leaf'), 'chance': 0.5}, match_block_ingredient('firmalife:drops_fruit_leaf')) global_loot_modifier(rm, 'ice_shavings', 'firmalife:add_item', {'item': item_stack_codec('firmalife:ice_shavings')}, match_block_ingredient('firmalife:drops_ice_shavings')) diff --git a/resources/recipes.py b/resources/recipes.py index defc736b..6c6c1ebf 100644 --- a/resources/recipes.py +++ b/resources/recipes.py @@ -257,7 +257,7 @@ def chisel_stair_slab(name: str, ingredient: str): oven_recipe(rm, 'lasagna', not_rotten('firmalife:food/raw_lasagna'), 400, result_item=item_stack_provider('firmalife:food/cooked_lasagna')) # Firmalife Recipes - knapping_type(rm, 'pumpkin', '1 #firmalife:pumpkin_knapping', None, 'tfc:item.knapping.leather', False, False, False, 'tfc:pumpkin') + knapping_type(rm, 'pumpkin', {'ingredient': not_rotten('#firmalife:pumpkin_knapping'), 'count': 1}, None, 'tfc:item.knapping.leather', False, False, False, 'tfc:pumpkin') for carving, pattern in CARVINGS.items(): pumpkin_knapping(rm, carving, pattern, 'firmalife:carved_pumpkin/%s' % carving) diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/HydroponicPlanterBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/HydroponicPlanterBlockEntity.java index 51ffb3c2..be96f4b9 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/HydroponicPlanterBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/HydroponicPlanterBlockEntity.java @@ -18,7 +18,7 @@ public static void hydroponicServerTick(Level level, BlockPos pos, BlockState st planter.checkForLastTickSync(); if (level.getGameTime() % (80 + (pos.getZ() % 4)) == 0 && planter.isClimateValid()) { - final Fluid fluid = SprinklerBlockEntity.searchForFluid(level, pos, Direction.DOWN); + final Fluid fluid = SprinklerBlockEntity.searchForFluid(level, pos, Direction.DOWN, false); final boolean valid = fluid != null; if (valid != planter.hasPipe) { diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SprinklerBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SprinklerBlockEntity.java index bd5a8668..f0689f63 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SprinklerBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SprinklerBlockEntity.java @@ -9,18 +9,25 @@ import com.eerussianguy.firmalife.common.blocks.greenhouse.PumpingStationBlock; import com.eerussianguy.firmalife.common.blocks.greenhouse.SprinklerBlock; import com.eerussianguy.firmalife.common.blocks.greenhouse.SprinklerPipeBlock; +import com.eerussianguy.firmalife.config.FLConfig; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; import org.jetbrains.annotations.Nullable; +import net.dries007.tfc.common.TFCTags; import net.dries007.tfc.common.blockentities.TFCBlockEntity; import net.dries007.tfc.common.blocks.DirectionPropertyBlock; +import net.dries007.tfc.common.capabilities.Capabilities; import net.dries007.tfc.common.capabilities.FluidTankCallback; import net.dries007.tfc.util.Helpers; @@ -31,7 +38,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Sprin { if (level.getGameTime() % (80 + (pos.getZ() % 4)) == 0 && sprinkler.valid && state.getBlock() instanceof AbstractSprinklerBlock block) { - final Fluid fluid = searchForFluid(level, pos, block instanceof SprinklerBlock ? Direction.UP : Direction.DOWN); + final Fluid fluid = searchForFluid(level, pos, block instanceof SprinklerBlock ? Direction.UP : Direction.DOWN, true); final boolean valid = fluid != null; if (valid) { @@ -56,8 +63,30 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Sprin * @return A fluid if found, otherwise {@code null} */ @Nullable - public static Fluid searchForFluid(Level level, BlockPos start, Direction pipeDirection) + public static Fluid searchForFluid(Level level, BlockPos start, Direction pipeDirection, boolean drain) { + if (!FLConfig.SERVER.usePipesForSprinklers.get()) + { + final BlockPos checkPos = start.relative(pipeDirection); + final BlockEntity be = level.getBlockEntity(checkPos); + if (be != null) + { + final IFluidHandler cap = Helpers.getCapability(be, Capabilities.FLUID); + if (cap != null) + { + final Fluid fluid = cap.getFluidInTank(0).getFluid(); + if (fluid != Fluids.EMPTY && Helpers.isFluid(fluid, TFCTags.Fluids.ANY_FRESH_WATER)) + { + if (drain) + { + cap.drain(1, IFluidHandler.FluidAction.EXECUTE); + } + return fluid; + } + } + } + return null; + } final BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos(); final Queue queue = new ArrayDeque<>(); final Set seen = new ObjectOpenHashSet<>(64); diff --git a/src/main/java/com/eerussianguy/firmalife/common/items/SprinklerItem.java b/src/main/java/com/eerussianguy/firmalife/common/items/SprinklerItem.java index b4e37864..440521c4 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/items/SprinklerItem.java +++ b/src/main/java/com/eerussianguy/firmalife/common/items/SprinklerItem.java @@ -2,6 +2,7 @@ import java.util.Map; import com.eerussianguy.firmalife.common.blocks.greenhouse.SprinklerPipeBlock; +import com.eerussianguy.firmalife.config.FLConfig; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.BlockItem; @@ -72,6 +73,6 @@ private BlockState getPlacementState(Block block, BlockPlaceContext context) private boolean isPipe(Level level, BlockPos pos) { - return level.getBlockState(pos).getBlock() instanceof SprinklerPipeBlock; + return level.getBlockState(pos).getBlock() instanceof SprinklerPipeBlock || !FLConfig.SERVER.usePipesForSprinklers.get(); } } diff --git a/src/main/java/com/eerussianguy/firmalife/config/FLServerConfig.java b/src/main/java/com/eerussianguy/firmalife/config/FLServerConfig.java index be728e8f..254c2221 100644 --- a/src/main/java/com/eerussianguy/firmalife/config/FLServerConfig.java +++ b/src/main/java/com/eerussianguy/firmalife/config/FLServerConfig.java @@ -36,6 +36,7 @@ public class FLServerConfig public final IntValue greenhouseRadius; public final IntValue cellarRadius; public final BooleanValue mechanicalPowerCheatMode; + public final BooleanValue usePipesForSprinklers; FLServerConfig(Builder innerBuilder) @@ -67,6 +68,7 @@ public class FLServerConfig greenhouseRadius = builder.apply("greenhouseRadius").comment("The max bounded distance from the climate station a greenhouse wall can be. Higher numbers = more lag.").defineInRange("greenhouseRadius", 15, 1, 128); cellarRadius = builder.apply("cellarRadius").comment("The max bounded distance from the climate station a cellar wall can be. Higher numbers = more lag.").defineInRange("cellarRadius", 15, 1, 128); mechanicalPowerCheatMode = builder.apply("mechanicalPowerCheatMode").comment("If true, the tumbler and the pumping station work magically with a redstone signal and no power required.").define("mechanicalPowerCheatMode", false); + usePipesForSprinklers = builder.apply("usePipesForSprinklers").comment("If true, sprinkler will not accept firmalife pipes and will instead require something that exposes a fluid capability, eg. a barrel.").define("usePipesForSprinklers", true); innerBuilder.pop().push("foodTraits"); diff --git a/src/main/resources/data/firmalife/loot_modifiers/rennet.json b/src/main/resources/data/firmalife/loot_modifiers/rennet.json index 87ec6a95..0813ae7e 100644 --- a/src/main/resources/data/firmalife/loot_modifiers/rennet.json +++ b/src/main/resources/data/firmalife/loot_modifiers/rennet.json @@ -12,6 +12,6 @@ ], "item": { "id": "firmalife:rennet", - "Count": 2 + "Count": 4 } } \ No newline at end of file diff --git a/src/main/resources/data/firmalife/loot_modifiers/rennet_three.json b/src/main/resources/data/firmalife/loot_modifiers/rennet_three.json index 72919678..553f0551 100644 --- a/src/main/resources/data/firmalife/loot_modifiers/rennet_three.json +++ b/src/main/resources/data/firmalife/loot_modifiers/rennet_three.json @@ -12,6 +12,6 @@ ], "item": { "id": "firmalife:rennet", - "Count": 3 + "Count": 6 } } \ No newline at end of file diff --git a/src/main/resources/data/firmalife/tfc/knapping_types/pumpkin.json b/src/main/resources/data/firmalife/tfc/knapping_types/pumpkin.json index fe470fd2..c12b6def 100644 --- a/src/main/resources/data/firmalife/tfc/knapping_types/pumpkin.json +++ b/src/main/resources/data/firmalife/tfc/knapping_types/pumpkin.json @@ -2,7 +2,10 @@ "__comment__": "This file was automatically created by mcresources", "input": { "ingredient": { - "tag": "firmalife:pumpkin_knapping" + "type": "tfc:not_rotten", + "ingredient": { + "tag": "firmalife:pumpkin_knapping" + } }, "count": 1 },