use of mekanism.common.tile.prefab.TileEntityMultiblock in project Mekanism by mekanism.
the class PacketDropperUse method handle.
@Override
public void handle(NetworkEvent.Context context) {
PlayerEntity player = context.getSender();
if (player == null || tankId < 0) {
return;
}
ItemStack stack = player.inventory.getCarried();
if (!stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) {
TileEntityMekanism tile = WorldUtils.getTileEntity(TileEntityMekanism.class, player.level, pos);
if (tile != null) {
if (tile instanceof TileEntityMultiblock) {
MultiblockData structure = ((TileEntityMultiblock<?>) tile).getMultiblock();
if (structure.isFormed()) {
handleTankType(structure, player, stack, new Coord4D(structure.getBounds().getCenter(), player.level));
}
} else {
if (action == DropperAction.DUMP_TANK && !player.isCreative()) {
// If the dropper is being used to dump the tank and the player is not in creative
// check if the block the tank is in is a tiered block and if it is, and it is creative
// don't allow clearing the tank
Block block = tile.getBlockType();
if (Attribute.has(block, AttributeTier.class) && Attribute.get(block, AttributeTier.class).getTier().getBaseTier() == BaseTier.CREATIVE) {
return;
}
}
handleTankType(tile, player, stack, tile.getTileCoord());
}
}
}
}
Aggregations