Skip to content

Commit 845d199

Browse files
committed
you should drop your stuff before poping!
1 parent 1c4ad64 commit 845d199

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/com/simibubi/create/content/contraptions/Contraption.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@
6868
import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlockEntity;
6969
import com.simibubi.create.content.logistics.crate.CreativeCrateBlockEntity;
7070
import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlockEntity;
71+
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
7172
import com.simibubi.create.content.redstone.contact.RedstoneContactBlock;
7273
import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
7374
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
7475
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
76+
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
77+
import com.simibubi.create.foundation.item.ItemHelper;
7578
import com.simibubi.create.foundation.utility.BlockHelper;
7679
import com.simibubi.create.infrastructure.config.AllConfigs;
7780

@@ -94,6 +97,8 @@
9497
import net.minecraft.network.protocol.game.DebugPackets;
9598
import net.minecraft.resources.ResourceLocation;
9699
import net.minecraft.server.level.ServerLevel;
100+
import net.minecraft.world.Container;
101+
import net.minecraft.world.Containers;
97102
import net.minecraft.world.entity.Entity;
98103
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
99104
import net.minecraft.world.item.ItemStack;
@@ -1168,6 +1173,20 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11681173
if (targetPos.getY() == world.getMinBuildHeight())
11691174
targetPos = targetPos.above();
11701175
world.levelEvent(2001, targetPos, Block.getId(state));
1176+
if(state.hasBlockEntity()){
1177+
CompoundTag tag = block.nbt();
1178+
if(tag != null) {
1179+
BlockEntity blockEntity = BlockEntity.loadStatic(targetPos, state, tag);
1180+
if (blockEntity instanceof Container container)
1181+
Containers.dropContents(world, targetPos, container);
1182+
else if (blockEntity instanceof ItemVaultBlockEntity vault)
1183+
ItemHelper.dropContents(world, targetPos, vault.getInventoryOfBlock());
1184+
else if (blockEntity instanceof SmartBlockEntity sbe){
1185+
sbe.setLevel(world);
1186+
sbe.destroy();
1187+
}
1188+
}
1189+
}
11711190
Block.dropResources(state, world, targetPos, null);
11721191
continue;
11731192
}

0 commit comments

Comments
 (0)