use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class GuiGauge method renderToolTip.
@Override
public void renderToolTip(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
super.renderToolTip(matrix, mouseX, mouseY);
ItemStack stack = minecraft.player.inventory.getCarried();
EnumColor color = getGaugeColor().getColor();
if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator && color != null) {
if (gui() instanceof GuiMekanismTile) {
TileEntityMekanism tile = ((GuiMekanismTile<?, ?>) gui()).getTileEntity();
if (tile instanceof ISideConfiguration && getTransmission() != null) {
DataType dataType = null;
ConfigInfo config = ((ISideConfiguration) tile).getConfig().getConfig(getTransmission());
if (config != null) {
Set<DataType> supportedDataTypes = config.getSupportedDataTypes();
for (DataType type : supportedDataTypes) {
if (type.getColor() == color) {
dataType = type;
break;
}
}
}
if (dataType == null) {
displayTooltip(matrix, MekanismLang.GENERIC_PARENTHESIS.translateColored(color, color.getName()), mouseX, mouseY);
} else {
displayTooltip(matrix, MekanismLang.GENERIC_WITH_PARENTHESIS.translateColored(color, dataType, color.getName()), mouseX, mouseY);
}
}
}
} else {
List<ITextComponent> list = new ArrayList<>();
if (getLabel() != null) {
list.add(getLabel());
}
list.addAll(getTooltipText());
displayTooltips(matrix, list, mouseX, mouseY);
}
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class BlockEnergyCube method getShape.
@Nonnull
@Override
@Deprecated
public VoxelShape getShape(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) {
TileEntityEnergyCube energyCube = WorldUtils.getTileEntity(TileEntityEnergyCube.class, world, pos, true);
int index;
if (energyCube == null) {
// Default to facing north all enabled
index = getIndex(1, 1, 1, 1, 1, 1, false, false);
} else {
ConfigInfo energyConfig = energyCube.configComponent.getConfig(TransmissionType.ENERGY);
if (energyConfig == null) {
// Default to facing north all enabled
index = getIndex(1, 1, 1, 1, 1, 1, false, false);
} else {
Direction facing = Attribute.get(this, AttributeStateFacing.class).getDirection(state);
index = getIndex(// top
isSideEnabled(energyConfig, facing, Direction.UP), // bottom
isSideEnabled(energyConfig, facing, Direction.DOWN), // front
isSideEnabled(energyConfig, facing, Direction.SOUTH), // back
isSideEnabled(energyConfig, facing, Direction.NORTH), // left
isSideEnabled(energyConfig, facing, Direction.EAST), // right
isSideEnabled(energyConfig, facing, Direction.WEST), facing == Direction.EAST || facing == Direction.WEST, facing == Direction.DOWN || facing == Direction.UP);
}
}
return bounds[index];
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class ModelEnergyCube method renderSidesBatched.
public void renderSidesBatched(@Nonnull TileEntityEnergyCube tile, @Nonnull MatrixStack matrix, @Nonnull IRenderTypeBuffer renderer, int light, int overlayLight) {
Set<RelativeSide> enabledSides = EnumSet.noneOf(RelativeSide.class);
Set<RelativeSide> outputSides = EnumSet.noneOf(RelativeSide.class);
ConfigInfo config = tile.getConfig().getConfig(TransmissionType.ENERGY);
if (config != null) {
for (RelativeSide side : EnumUtils.SIDES) {
ISlotInfo slotInfo = config.getSlotInfo(side);
if (slotInfo != null) {
if (slotInfo.canInput()) {
enabledSides.add(side);
} else if (slotInfo.canOutput()) {
enabledSides.add(side);
outputSides.add(side);
}
}
}
}
renderSidesBatched(matrix, renderer, light, overlayLight, enabledSides, outputSides, false);
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class ISideConfiguration method getActiveDataType.
@Nullable
default DataType getActiveDataType(Object container) {
ConfigInfo info = null;
TileComponentConfig config = getConfig();
if (container instanceof IGasTank && config.supports(TransmissionType.GAS)) {
info = config.getConfig(TransmissionType.GAS);
} else if (container instanceof IInfusionTank && config.supports(TransmissionType.INFUSION)) {
info = config.getConfig(TransmissionType.INFUSION);
} else if (container instanceof IPigmentTank && config.supports(TransmissionType.PIGMENT)) {
info = config.getConfig(TransmissionType.PIGMENT);
} else if (container instanceof ISlurryTank && config.supports(TransmissionType.SLURRY)) {
info = config.getConfig(TransmissionType.SLURRY);
} else if (container instanceof IExtendedFluidTank && config.supports(TransmissionType.FLUID)) {
info = config.getConfig(TransmissionType.FLUID);
} else if (container instanceof IInventorySlot && config.supports(TransmissionType.ITEM)) {
info = config.getConfig(TransmissionType.ITEM);
}
if (info != null) {
List<DataType> types = info.getDataTypeForContainer(container);
int count = types.size();
// of <= size - 1 to cut down slightly on the calculations
if (count > 0 && count < info.getSupportedDataTypes().size()) {
return types.get(0);
}
}
return null;
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileComponentConfig method setupOutputConfig.
public ConfigInfo setupOutputConfig(TransmissionType type, Object container, RelativeSide... sides) {
ConfigInfo config = getConfig(type);
if (config != null) {
config.addSlotInfo(DataType.OUTPUT, createInfo(type, false, true, container));
config.setDataType(DataType.OUTPUT, sides);
config.setEjecting(true);
}
return config;
}
Aggregations