Fix belt funnel disappearing on contraption

This commit is contained in:
Snownee 2020-12-25 17:34:45 +08:00
parent e554c5a3ff
commit 6df81c8272
2 changed files with 8 additions and 9 deletions

View file

@ -59,7 +59,6 @@ import net.minecraft.block.ChestBlock;
import net.minecraft.block.DoorBlock; import net.minecraft.block.DoorBlock;
import net.minecraft.block.IWaterLoggable; import net.minecraft.block.IWaterLoggable;
import net.minecraft.block.PressurePlateBlock; import net.minecraft.block.PressurePlateBlock;
import net.minecraft.block.SlimeBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState; import net.minecraft.fluid.IFluidState;
@ -713,7 +712,7 @@ public abstract class Contraption {
return nbt; return nbt;
} }
public void removeBlocksFromWorld(IWorld world, BlockPos offset) { public void removeBlocksFromWorld(World world, BlockPos offset) {
storage.values() storage.values()
.forEach(MountedStorage::removeStorageFromWorld); .forEach(MountedStorage::removeStorageFromWorld);
fluidStorage.values() fluidStorage.values()
@ -727,8 +726,7 @@ public abstract class Contraption {
if (brittles != BlockMovementTraits.isBrittle(block.state)) if (brittles != BlockMovementTraits.isBrittle(block.state))
continue; continue;
BlockPos add = block.pos.add(anchor) BlockPos add = block.pos.add(anchor).add(offset);
.add(offset);
if (customBlockRemoval(world, add, block.state)) if (customBlockRemoval(world, add, block.state))
continue; continue;
BlockState oldState = world.getBlockState(add); BlockState oldState = world.getBlockState(add);
@ -737,9 +735,7 @@ public abstract class Contraption {
iterator.remove(); iterator.remove();
world.getWorld() world.getWorld()
.removeTileEntity(add); .removeTileEntity(add);
int flags = 67; int flags = BlockFlags.IS_MOVING | BlockFlags.NO_NEIGHBOR_DROPS | BlockFlags.UPDATE_NEIGHBORS;
if (blockIn instanceof DoorBlock)
flags = flags | 32 | 16;
if (blockIn instanceof IWaterLoggable && oldState.has(BlockStateProperties.WATERLOGGED) if (blockIn instanceof IWaterLoggable && oldState.has(BlockStateProperties.WATERLOGGED)
&& oldState.get(BlockStateProperties.WATERLOGGED) && oldState.get(BlockStateProperties.WATERLOGGED)
.booleanValue()) { .booleanValue()) {
@ -749,6 +745,10 @@ public abstract class Contraption {
world.setBlockState(add, Blocks.AIR.getDefaultState(), flags); world.setBlockState(add, Blocks.AIR.getDefaultState(), flags);
} }
} }
for (BlockInfo block : blocks.values()) {
BlockPos add = block.pos.add(anchor).add(offset);
world.markAndNotifyBlock(add, null, block.state, Blocks.AIR.getDefaultState(), BlockFlags.IS_MOVING | BlockFlags.DEFAULT);
}
} }
public void addBlocksToWorld(World world, StructureTransform transform) { public void addBlocksToWorld(World world, StructureTransform transform) {

View file

@ -7,7 +7,6 @@ import java.util.Set;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
@ -40,7 +39,7 @@ public abstract class TranslatingContraption extends Contraption {
} }
@Override @Override
public void removeBlocksFromWorld(IWorld world, BlockPos offset) { public void removeBlocksFromWorld(World world, BlockPos offset) {
int count = blocks.size(); int count = blocks.size();
super.removeBlocksFromWorld(world, offset); super.removeBlocksFromWorld(world, offset);
if (count != blocks.size()) { if (count != blocks.size()) {