|
57 | 57 | import com.simibubi.create.content.contraptions.pulley.PulleyBlock.MagnetBlock;
|
58 | 58 | import com.simibubi.create.content.contraptions.pulley.PulleyBlock.RopeBlock;
|
59 | 59 | import com.simibubi.create.content.contraptions.pulley.PulleyBlockEntity;
|
| 60 | +import com.simibubi.create.content.decoration.placard.PlacardBlockEntity; |
60 | 61 | import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock;
|
61 | 62 | import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour;
|
62 | 63 | import com.simibubi.create.content.kinetics.base.IRotate;
|
|
68 | 69 | import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlockEntity;
|
69 | 70 | import com.simibubi.create.content.logistics.crate.CreativeCrateBlockEntity;
|
70 | 71 | import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlockEntity;
|
| 72 | +import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity; |
71 | 73 | import com.simibubi.create.content.redstone.contact.RedstoneContactBlock;
|
72 | 74 | import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
|
73 | 75 | import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
|
74 | 76 | 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; |
75 | 79 | import com.simibubi.create.foundation.utility.BlockHelper;
|
76 | 80 | import com.simibubi.create.infrastructure.config.AllConfigs;
|
77 | 81 |
|
|
94 | 98 | import net.minecraft.network.protocol.game.DebugPackets;
|
95 | 99 | import net.minecraft.resources.ResourceLocation;
|
96 | 100 | import net.minecraft.server.level.ServerLevel;
|
| 101 | +import net.minecraft.world.Container; |
| 102 | +import net.minecraft.world.Containers; |
97 | 103 | import net.minecraft.world.entity.Entity;
|
98 | 104 | import net.minecraft.world.entity.ai.village.poi.PoiTypes;
|
99 | 105 | import net.minecraft.world.item.ItemStack;
|
@@ -1168,6 +1174,22 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
|
1168 | 1174 | if (targetPos.getY() == world.getMinBuildHeight())
|
1169 | 1175 | targetPos = targetPos.above();
|
1170 | 1176 | 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 | + } |
1171 | 1193 | Block.dropResources(state, world, targetPos, null);
|
1172 | 1194 | continue;
|
1173 | 1195 | }
|
|
0 commit comments