use of mekanism.common.lib.multiblock.MultiblockData in project Mekanism by mekanism.
the class TileEntityStructuralMultiblock method onActivate.
@Override
public ActionResultType onActivate(PlayerEntity player, Hand hand, ItemStack stack) {
for (Map.Entry<MultiblockManager<?>, Structure> entry : structures.entrySet()) {
Structure structure = entry.getValue();
IMultiblock<?> master = structure.getController();
if (master != null) {
MultiblockData data = getMultiblockData(structure);
if (data.isFormed() && structuralGuiAccessAllowed(entry.getKey().getNameLower())) {
// make sure this block is on the structure first
if (data.getBounds().getRelativeLocation(getBlockPos()).isWall()) {
return master.onActivate(player, hand, stack);
}
}
}
}
return ActionResultType.PASS;
}
use of mekanism.common.lib.multiblock.MultiblockData in project Mekanism by mekanism.
the class LookingAtUtils method addInfo.
public static void addInfo(LookingAtHelper info, @Nonnull TileEntity tile, boolean displayTanks, boolean displayFluidTanks) {
MultiblockData structure = getMultiblock(tile);
Optional<IStrictEnergyHandler> energyCapability = CapabilityUtils.getCapability(tile, Capabilities.STRICT_ENERGY_CAPABILITY, null).resolve();
if (energyCapability.isPresent()) {
displayEnergy(info, energyCapability.get());
} else if (structure != null && structure.isFormed()) {
// Special handling to allow viewing the energy of multiblock's when looking at things other than the ports
displayEnergy(info, structure);
}
if (displayTanks) {
// Fluid - only add it to our own tiles in which we disable the default display for
if (displayFluidTanks && tile instanceof TileEntityUpdateable) {
Optional<IFluidHandler> fluidCapability = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).resolve();
if (fluidCapability.isPresent()) {
displayFluid(info, fluidCapability.get());
} else if (structure != null && structure.isFormed()) {
// Special handling to allow viewing the fluid in a multiblock when looking at things other than the ports
displayFluid(info, structure);
}
}
// Chemicals
addInfo(tile, structure, Capabilities.GAS_HANDLER_CAPABILITY, multiblock -> multiblock.getGasTanks(null), info, MekanismLang.GAS, Current.GAS, CurrentType.GAS);
addInfo(tile, structure, Capabilities.INFUSION_HANDLER_CAPABILITY, multiblock -> multiblock.getInfusionTanks(null), info, MekanismLang.INFUSE_TYPE, Current.INFUSION, CurrentType.INFUSION);
addInfo(tile, structure, Capabilities.PIGMENT_HANDLER_CAPABILITY, multiblock -> multiblock.getPigmentTanks(null), info, MekanismLang.PIGMENT, Current.PIGMENT, CurrentType.PIGMENT);
addInfo(tile, structure, Capabilities.SLURRY_HANDLER_CAPABILITY, multiblock -> multiblock.getSlurryTanks(null), info, MekanismLang.SLURRY, Current.SLURRY, CurrentType.SLURRY);
}
}
use of mekanism.common.lib.multiblock.MultiblockData 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