Fix Silkworms not applying to certain modded leaves like TFC

This commit is contained in:
thedarkcolour 2025-02-05 15:31:30 -08:00
parent b2ddaacc56
commit be579174f3
No known key found for this signature in database
GPG Key ID: 86B37B3575FD5976
4 changed files with 12 additions and 10 deletions

View File

@ -1,5 +1,6 @@
## Ex Deorum 3.6
- Implement custom Compressed Sieve types. Works the same as with sieves, just replace `sieve_materials` with `compressed_sieve_materials`
- Fix silkworms not applying to certain modded leaves like TFC
## Ex Deorum 3.5
- Remove Yellorium Dust sieve drop (#116)

View File

@ -38,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.neoforged.api.distmarker.Dist;
import net.neoforged.fml.loading.FMLEnvironment;
import org.jetbrains.annotations.Nullable;
@ -46,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");
@ -55,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<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);

View File

@ -28,7 +28,6 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
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.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.state.BlockState;
@ -92,10 +91,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.getValue(LeavesBlock.DISTANCE))
.setValue(LeavesBlock.PERSISTENT, state.getValue(LeavesBlock.PERSISTENT)),
2);
InfestedLeavesBlock.setBlock(level, targetPos, state);
var te = level.getBlockEntity(targetPos);
// Set mimic state of other block

View File

@ -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);