From 903913c7000e4357201abad5d6e3962bb0b56143 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:12:56 -0800 Subject: [PATCH] Fix Silkworms not applying to certain modded leaves like TFC --- changelog.md | 3 +++ .../exdeorum/block/InfestedLeavesBlock.java | 13 ++++++++----- .../blockentity/InfestedLeavesBlockEntity.java | 9 +-------- .../thedarkcolour/exdeorum/item/SilkWormItem.java | 6 ++---- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index ad75983c..52ca9beb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## Ex Deorum 1.44 +- Fix Silkworms not applying to certain modded leaves like TFC + ## Ex Deorum 1.43 - Fix sieve recipe bug with latest version of JEI diff --git a/src/main/java/thedarkcolour/exdeorum/block/InfestedLeavesBlock.java b/src/main/java/thedarkcolour/exdeorum/block/InfestedLeavesBlock.java index 54f410db..e6732b42 100644 --- a/src/main/java/thedarkcolour/exdeorum/block/InfestedLeavesBlock.java +++ b/src/main/java/thedarkcolour/exdeorum/block/InfestedLeavesBlock.java @@ -19,12 +19,8 @@ package thedarkcolour.exdeorum.block; import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.BlockParticleOption; -import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -42,7 +38,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.loading.FMLEnvironment; import org.jetbrains.annotations.Nullable; @@ -50,6 +45,7 @@ import thedarkcolour.exdeorum.blockentity.InfestedLeavesBlockEntity; import thedarkcolour.exdeorum.client.RenderUtil; import thedarkcolour.exdeorum.config.EConfig; import thedarkcolour.exdeorum.registry.EBlockEntities; +import thedarkcolour.exdeorum.registry.EBlocks; public class InfestedLeavesBlock extends LeavesBlock implements EntityBlock { public static final BooleanProperty FULLY_INFESTED = BooleanProperty.create("fully_infested"); @@ -59,6 +55,13 @@ public class InfestedLeavesBlock extends LeavesBlock implements EntityBlock { registerDefaultState(defaultBlockState().setValue(FULLY_INFESTED, false)); } + public static void setBlock(Level level, BlockPos pos, BlockState fromState) { + level.setBlock(pos, EBlocks.INFESTED_LEAVES.get().defaultBlockState() + .setValue(LeavesBlock.DISTANCE, fromState.hasProperty(LeavesBlock.DISTANCE) ? fromState.getValue(LeavesBlock.DISTANCE) : 0) + .setValue(LeavesBlock.PERSISTENT, fromState.hasProperty(LeavesBlock.PERSISTENT) ? fromState.getValue(LeavesBlock.PERSISTENT) : false), + 2); + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java index 6891d262..4c49ea2f 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java @@ -27,12 +27,8 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.tags.BlockTags; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.ModelData; -import net.minecraftforge.client.model.data.ModelProperty; -import org.jetbrains.annotations.NotNull; import thedarkcolour.exdeorum.block.InfestedLeavesBlock; import thedarkcolour.exdeorum.registry.EBlockEntities; import thedarkcolour.exdeorum.registry.EBlocks; @@ -76,10 +72,7 @@ public class InfestedLeavesBlockEntity extends EBlockEntity { // DO NOT SPREAD TO ALREADY INFESTED LEAVES if (state.is(BlockTags.LEAVES) && state.getBlock() != EBlocks.INFESTED_LEAVES.get()) { // Spread and keep distance/persistent properties - level.setBlock(targetPos, EBlocks.INFESTED_LEAVES.get().defaultBlockState() - .setValue(LeavesBlock.DISTANCE, state.hasProperty(LeavesBlock.DISTANCE) ? state.getValue(LeavesBlock.DISTANCE) : 0) - .setValue(LeavesBlock.PERSISTENT, state.hasProperty(LeavesBlock.PERSISTENT) ? state.getValue(LeavesBlock.PERSISTENT) : false), - 2); + InfestedLeavesBlock.setBlock(level, targetPos, state); var te = level.getBlockEntity(targetPos); // Set mimic state of other block diff --git a/src/main/java/thedarkcolour/exdeorum/item/SilkWormItem.java b/src/main/java/thedarkcolour/exdeorum/item/SilkWormItem.java index ebbc89c6..27347146 100644 --- a/src/main/java/thedarkcolour/exdeorum/item/SilkWormItem.java +++ b/src/main/java/thedarkcolour/exdeorum/item/SilkWormItem.java @@ -25,7 +25,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.block.LeavesBlock; +import thedarkcolour.exdeorum.block.InfestedLeavesBlock; import thedarkcolour.exdeorum.blockentity.InfestedLeavesBlockEntity; import thedarkcolour.exdeorum.registry.EBlocks; import thedarkcolour.exdeorum.registry.ESounds; @@ -45,9 +45,7 @@ public class SilkWormItem extends Item { if (state.is(BlockTags.LEAVES) && state.getBlock() != EBlocks.INFESTED_LEAVES.get()) { if (!level.isClientSide) { // Replace with infested block - level.setBlock(pos, EBlocks.INFESTED_LEAVES.get().defaultBlockState() - .setValue(LeavesBlock.DISTANCE, state.getValue(LeavesBlock.DISTANCE)) - .setValue(LeavesBlock.PERSISTENT, state.getValue(LeavesBlock.PERSISTENT)), 2); + InfestedLeavesBlock.setBlock(level, pos, state); level.playSound(null, pos, ESounds.SILK_WORM_INFEST.get(), SoundSource.BLOCKS);