Skip to content

Commit 77e54dc

Browse files
committed
you should drop your stuff before poping!
1 parent 1c4ad64 commit 77e54dc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
import javax.annotation.Nullable;
2424

25+
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
26+
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
27+
28+
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
29+
30+
import com.simibubi.create.foundation.item.ItemHelper;
31+
2532
import org.apache.commons.lang3.tuple.MutablePair;
2633
import org.apache.commons.lang3.tuple.Pair;
2734

@@ -94,6 +101,8 @@
94101
import net.minecraft.network.protocol.game.DebugPackets;
95102
import net.minecraft.resources.ResourceLocation;
96103
import net.minecraft.server.level.ServerLevel;
104+
import net.minecraft.world.Container;
105+
import net.minecraft.world.Containers;
97106
import net.minecraft.world.entity.Entity;
98107
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
99108
import net.minecraft.world.item.ItemStack;
@@ -1168,6 +1177,20 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11681177
if (targetPos.getY() == world.getMinBuildHeight())
11691178
targetPos = targetPos.above();
11701179
world.levelEvent(2001, targetPos, Block.getId(state));
1180+
if(state.hasBlockEntity()){
1181+
CompoundTag tag = block.nbt();
1182+
if(tag != null) {
1183+
BlockEntity blockEntity = BlockEntity.loadStatic(targetPos, state, tag);
1184+
if (blockEntity instanceof Container container)
1185+
Containers.dropContents(world, targetPos, container);
1186+
else if (blockEntity instanceof ItemVaultBlockEntity vault)
1187+
ItemHelper.dropContents(world, targetPos, vault.getInventoryOfBlock());
1188+
else if (blockEntity instanceof SmartBlockEntity sbe){
1189+
sbe.setLevel(world);
1190+
sbe.destroy();
1191+
}
1192+
}
1193+
}
11711194
Block.dropResources(state, world, targetPos, null);
11721195
continue;
11731196
}

0 commit comments

Comments
 (0)