use of mekanism.api.RelativeSide 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.api.RelativeSide in project Mekanism by mekanism.
the class ModelEnergyCube method renderSidesBatched.
public void renderSidesBatched(@Nonnull ItemStack stack, EnergyCubeTier tier, @Nonnull MatrixStack matrix, @Nonnull IRenderTypeBuffer renderer, int light, int overlayLight, boolean hasEffect) {
Set<RelativeSide> enabledSides;
Set<RelativeSide> outputSides;
CompoundNBT configData = ItemDataUtils.getDataMapIfPresent(stack);
if (configData != null && configData.contains(NBTConstants.COMPONENT_CONFIG, NBT.TAG_COMPOUND)) {
enabledSides = EnumSet.noneOf(RelativeSide.class);
outputSides = EnumSet.noneOf(RelativeSide.class);
CompoundNBT sideConfig = configData.getCompound(NBTConstants.COMPONENT_CONFIG).getCompound(NBTConstants.CONFIG + TransmissionType.ENERGY.ordinal());
// TODO: Maybe improve on this, but for now this is a decent way of making it not have disabled sides show
for (RelativeSide side : EnumUtils.SIDES) {
DataType dataType = DataType.byIndexStatic(sideConfig.getInt(NBTConstants.SIDE + side.ordinal()));
if (dataType.equals(DataType.INPUT)) {
enabledSides.add(side);
} else if (dataType.equals(DataType.OUTPUT)) {
enabledSides.add(side);
outputSides.add(side);
}
}
} else {
enabledSides = EnumSet.allOf(RelativeSide.class);
if (tier == EnergyCubeTier.CREATIVE) {
outputSides = EnumSet.allOf(RelativeSide.class);
} else {
outputSides = Collections.singleton(RelativeSide.FRONT);
}
}
renderSidesBatched(matrix, renderer, light, overlayLight, enabledSides, outputSides, hasEffect);
}
use of mekanism.api.RelativeSide in project Mekanism by mekanism.
the class TileEntityGenerator method onUpdateServer.
@Override
protected void onUpdateServer() {
super.onUpdateServer();
if (MekanismUtils.canFunction(this)) {
// TODO: Cache the directions or maybe even make some generators have a side config/ejector component and move this to the ejector component?
Set<Direction> emitDirections = EnumSet.noneOf(Direction.class);
Direction direction = getDirection();
for (RelativeSide energySide : getEnergySides()) {
emitDirections.add(energySide.getDirection(direction));
}
CableUtils.emit(emitDirections, energyContainer, this, getMaxOutput());
}
}
use of mekanism.api.RelativeSide in project Mekanism by mekanism.
the class TileComponentConfig method read.
@Override
public void read(CompoundNBT nbtTags) {
if (nbtTags.contains(NBTConstants.COMPONENT_CONFIG, NBT.TAG_COMPOUND)) {
CompoundNBT configNBT = nbtTags.getCompound(NBTConstants.COMPONENT_CONFIG);
Set<Direction> directionsToUpdate = EnumSet.noneOf(Direction.class);
for (Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
TransmissionType type = entry.getKey();
ConfigInfo info = entry.getValue();
info.setEjecting(configNBT.getBoolean(NBTConstants.EJECT + type.ordinal()));
CompoundNBT sideConfig = configNBT.getCompound(NBTConstants.CONFIG + type.ordinal());
for (RelativeSide side : EnumUtils.SIDES) {
NBTUtils.setEnumIfPresent(sideConfig, NBTConstants.SIDE + side.ordinal(), DataType::byIndexStatic, dataType -> {
if (info.getDataType(side) != dataType) {
info.setDataType(dataType, side);
if (tile.hasLevel()) {
// If we aren't already loaded yet don't do any updates
Direction direction = side.getDirection(tile.getDirection());
sideChangedBasic(type, direction);
directionsToUpdate.add(direction);
}
}
});
}
}
WorldUtils.notifyNeighborsOfChange(tile.getLevel(), tile.getBlockPos(), directionsToUpdate);
}
}
use of mekanism.api.RelativeSide in project Mekanism by mekanism.
the class TileComponentConfig method readFromUpdateTag.
@Override
public void readFromUpdateTag(CompoundNBT updateTag) {
if (updateTag.contains(NBTConstants.COMPONENT_CONFIG, NBT.TAG_COMPOUND)) {
CompoundNBT configNBT = updateTag.getCompound(NBTConstants.COMPONENT_CONFIG);
for (Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
TransmissionType type = entry.getKey();
ConfigInfo info = entry.getValue();
CompoundNBT sideConfig = configNBT.getCompound(NBTConstants.CONFIG + type.ordinal());
for (RelativeSide side : EnumUtils.SIDES) {
NBTUtils.setEnumIfPresent(sideConfig, NBTConstants.SIDE + side.ordinal(), DataType::byIndexStatic, dataType -> info.setDataType(dataType, side));
}
}
}
}
Aggregations