|
68 | 68 | import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlockEntity; |
69 | 69 | import com.simibubi.create.content.logistics.crate.CreativeCrateBlockEntity; |
70 | 70 | import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlockEntity; |
| 71 | +import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity; |
71 | 72 | import com.simibubi.create.content.redstone.contact.RedstoneContactBlock; |
72 | 73 | import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock; |
73 | 74 | import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer; |
74 | 75 | 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; |
75 | 78 | import com.simibubi.create.foundation.utility.BlockHelper; |
76 | 79 | import com.simibubi.create.infrastructure.config.AllConfigs; |
77 | 80 |
|
|
94 | 97 | import net.minecraft.network.protocol.game.DebugPackets; |
95 | 98 | import net.minecraft.resources.ResourceLocation; |
96 | 99 | import net.minecraft.server.level.ServerLevel; |
| 100 | +import net.minecraft.world.Container; |
| 101 | +import net.minecraft.world.Containers; |
97 | 102 | import net.minecraft.world.entity.Entity; |
98 | 103 | import net.minecraft.world.entity.ai.village.poi.PoiTypes; |
99 | 104 | import net.minecraft.world.item.ItemStack; |
@@ -1168,6 +1173,20 @@ public void addBlocksToWorld(Level world, StructureTransform transform) { |
1168 | 1173 | if (targetPos.getY() == world.getMinBuildHeight()) |
1169 | 1174 | targetPos = targetPos.above(); |
1170 | 1175 | 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 | + } |
1171 | 1190 | Block.dropResources(state, world, targetPos, null); |
1172 | 1191 | continue; |
1173 | 1192 | } |
|
0 commit comments