From 223afd98b95b7c3cb912f5d1dd037aa445369d12 Mon Sep 17 00:00:00 2001 From: EERussianguy Date: Fri, 9 Sep 2022 17:49:09 -0400 Subject: [PATCH] compat for beta 5, fix watering cans --- gradle.properties | 2 +- .../IronComposterBlockEntity.java | 41 +++++-------------- .../firmalife/common/items/FLItems.java | 2 +- .../common/items/WateringCanItem.java | 1 + 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/gradle.properties b/gradle.properties index bb5c7073..2c0a7f78 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ mixin_version=0.8.5 jei_version=9.7.1.232 patchouli_version=1.18.2-70 tfc_version=0.0.0-indev -tfc_identifier=3970479 \ No newline at end of file +tfc_identifier=3975434 \ No newline at end of file diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/IronComposterBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/IronComposterBlockEntity.java index 5451c406..f848749b 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/IronComposterBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/IronComposterBlockEntity.java @@ -6,7 +6,6 @@ import com.eerussianguy.firmalife.config.FLConfig; import net.dries007.tfc.common.blockentities.ComposterBlockEntity; import net.dries007.tfc.common.blockentities.TFCBlockEntities; -import net.dries007.tfc.common.blocks.devices.TFCComposterBlock; import net.dries007.tfc.config.TFCConfig; import net.dries007.tfc.util.climate.Climate; @@ -18,42 +17,22 @@ public IronComposterBlockEntity(BlockPos pos, BlockState state) } @Override - public void randomTick() + public long getReadyTicks() { - if (getGreen() >= 4 && getBrown() >= 4 & !isRotten()) + assert level != null; + final float rainfall = Climate.getRainfall(level, getBlockPos()); + long readyTicks = FLConfig.SERVER.ironComposterTicks.get(); // firmalife: divide ready time by 4 + if (TFCConfig.SERVER.composterRainfallCheck.get()) { - assert level != null; - final float rainfall = Climate.getRainfall(level, getBlockPos()); - long readyTicks = FLConfig.SERVER.ironComposterTicks.get(); // firmalife: divide ready time by 4 - if (TFCConfig.SERVER.composterRainfallCheck.get()) + if (rainfall < 150f) // inverted trapezoid wave { - if (rainfall < 150f) // inverted trapezoid wave - { - readyTicks *= (long) ((150f - rainfall) / 50f + 1f); - } - else if (rainfall > 350f) - { - readyTicks *= (long) ((rainfall - 350f) / 50f + 1f); - } + readyTicks *= (long) ((150f - rainfall) / 50f + 1f); } - if (getTicksSinceUpdate() > readyTicks) + else if (rainfall > 350f) { - setState(TFCComposterBlock.CompostType.READY); - markForSync(); + readyTicks *= (long) ((rainfall - 350f) / 50f + 1f); } } + return readyTicks; } - - private void setState(TFCComposterBlock.CompostType type) - { - assert level != null; - level.setBlockAndUpdate(getBlockPos(), level.getBlockState(getBlockPos()).setValue(TFCComposterBlock.TYPE, type)); - } - - private boolean isRotten() - { - assert level != null; - return level.getBlockState(getBlockPos()).getValue(TFCComposterBlock.TYPE) == TFCComposterBlock.CompostType.ROTTEN; - } - } diff --git a/src/main/java/com/eerussianguy/firmalife/common/items/FLItems.java b/src/main/java/com/eerussianguy/firmalife/common/items/FLItems.java index ca58d84d..6eca24bd 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/items/FLItems.java +++ b/src/main/java/com/eerussianguy/firmalife/common/items/FLItems.java @@ -53,7 +53,7 @@ public class FLItems public static final RegistryObject SEED_BALL = register("seed_ball", () -> new SeedBallItem(prop())); public static final RegistryObject SPOON = register("spoon", MISC); public static final RegistryObject TREATED_LUMBER = register("treated_lumber", MISC); - public static final RegistryObject WATERING_CAN = register("watering_can", () -> new WateringCanItem(prop())); + public static final RegistryObject WATERING_CAN = register("watering_can", () -> new WateringCanItem(prop().defaultDurability(20))); public static final Map> SPICES = Helpers.mapOfKeys(Spice.class, spice -> register("spice/" + spice.name(), MISC)); public static final Map> FOODS = Helpers.mapOfKeys(FLFood.class, food -> register("food/" + food.name(), () -> new DecayingItem(new Item.Properties().food(food.getFoodProperties()).tab(FOOD)))); diff --git a/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java b/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java index c5b09439..4709b7cd 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java +++ b/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java @@ -54,6 +54,7 @@ public void releaseUsing(ItemStack stack, Level level, LivingEntity entity, int receiver.addWater(0.25f); } } + stack.hurtAndBreak(1, entity, p -> p.broadcastBreakEvent(entity.getUsedItemHand())); } @Override