Skip to content

Commit 78a793b

Browse files
committed
you should drop your stuff before poping!
1 parent 1c4ad64 commit 78a793b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import com.simibubi.create.content.contraptions.pulley.PulleyBlock.MagnetBlock;
5858
import com.simibubi.create.content.contraptions.pulley.PulleyBlock.RopeBlock;
5959
import com.simibubi.create.content.contraptions.pulley.PulleyBlockEntity;
60+
import com.simibubi.create.content.decoration.placard.PlacardBlockEntity;
6061
import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock;
6162
import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour;
6263
import com.simibubi.create.content.kinetics.base.IRotate;
@@ -68,10 +69,13 @@
6869
import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlockEntity;
6970
import com.simibubi.create.content.logistics.crate.CreativeCrateBlockEntity;
7071
import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlockEntity;
72+
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
7173
import com.simibubi.create.content.redstone.contact.RedstoneContactBlock;
7274
import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
7375
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
7476
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
77+
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
78+
import com.simibubi.create.foundation.item.ItemHelper;
7579
import com.simibubi.create.foundation.utility.BlockHelper;
7680
import com.simibubi.create.infrastructure.config.AllConfigs;
7781

@@ -94,6 +98,8 @@
9498
import net.minecraft.network.protocol.game.DebugPackets;
9599
import net.minecraft.resources.ResourceLocation;
96100
import net.minecraft.server.level.ServerLevel;
101+
import net.minecraft.world.Container;
102+
import net.minecraft.world.Containers;
97103
import net.minecraft.world.entity.Entity;
98104
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
99105
import net.minecraft.world.item.ItemStack;
@@ -1168,6 +1174,22 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11681174
if (targetPos.getY() == world.getMinBuildHeight())
11691175
targetPos = targetPos.above();
11701176
world.levelEvent(2001, targetPos, Block.getId(state));
1177+
if(state.hasBlockEntity()){
1178+
CompoundTag tag = block.nbt();
1179+
if(tag != null) {
1180+
BlockEntity blockEntity = BlockEntity.loadStatic(targetPos, state, tag);
1181+
if (blockEntity instanceof Container container)
1182+
Containers.dropContents(world, targetPos, container);
1183+
else if (blockEntity instanceof ItemVaultBlockEntity vault)
1184+
ItemHelper.dropContents(world, targetPos, vault.getInventoryOfBlock());
1185+
else if (blockEntity instanceof PlacardBlockEntity placard)
1186+
Block.popResource(world, targetPos, placard.getHeldItem());
1187+
else if (blockEntity instanceof SmartBlockEntity sbe){
1188+
sbe.setLevel(world);
1189+
sbe.destroy();
1190+
}
1191+
}
1192+
}
11711193
Block.dropResources(state, world, targetPos, null);
11721194
continue;
11731195
}

0 commit comments

Comments
 (0)