|
22 | 22 |
|
23 | 23 | import javax.annotation.Nullable; |
24 | 24 |
|
| 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 | + |
25 | 32 | import org.apache.commons.lang3.tuple.MutablePair; |
26 | 33 | import org.apache.commons.lang3.tuple.Pair; |
27 | 34 |
|
|
94 | 101 | import net.minecraft.network.protocol.game.DebugPackets; |
95 | 102 | import net.minecraft.resources.ResourceLocation; |
96 | 103 | import net.minecraft.server.level.ServerLevel; |
| 104 | +import net.minecraft.world.Container; |
| 105 | +import net.minecraft.world.Containers; |
97 | 106 | import net.minecraft.world.entity.Entity; |
98 | 107 | import net.minecraft.world.entity.ai.village.poi.PoiTypes; |
99 | 108 | import net.minecraft.world.item.ItemStack; |
@@ -1168,6 +1177,20 @@ public void addBlocksToWorld(Level world, StructureTransform transform) { |
1168 | 1177 | if (targetPos.getY() == world.getMinBuildHeight()) |
1169 | 1178 | targetPos = targetPos.above(); |
1170 | 1179 | 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 | + } |
1171 | 1194 | Block.dropResources(state, world, targetPos, null); |
1172 | 1195 | continue; |
1173 | 1196 | } |
|
0 commit comments