use of reborncore.common.tile.TileLegacyMachineBase in project TechReborn by TechReborn.
the class SlotConfigPopupElement method draw.
@Override
public void draw(GuiBase gui) {
drawDefaultBackground(gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
super.draw(gui);
TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile);
IBlockAccess blockAccess = machine.getWorld();
BlockPos pos = machine.getPos();
IBlockState state = blockAccess.getBlockState(pos);
IBlockState actualState = state.getBlock().getDefaultState().getActualState(blockAccess, pos);
BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.getBlock().getDefaultState());
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
// left
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23);
// top
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F);
// centre
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F);
// bottom
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F);
// right
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F);
// back
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F);
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
}
use of reborncore.common.tile.TileLegacyMachineBase in project TechReborn by TechReborn.
the class ProbeProvider method addProbeInfo.
@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
euStyle = new ProgressStyle().backgroundColor(0xFF8B8B8B).borderColor(0xFF373737).alternateFilledColor(PowerSystem.getDisplayPower().altColour).filledColor(PowerSystem.getDisplayPower().colour);
euStyle.suffix(" " + PowerSystem.getDisplayPower().abbreviation);
TileEntity tile = world.getTileEntity(data.getPos());
if (tile instanceof IListInfoProvider) {
List<String> strs = new ArrayList<>();
((IListInfoProvider) tile).addInfo(strs, true);
for (String string : strs) {
probeInfo.text(string);
}
}
if (tile instanceof IEnergyInterfaceTile) {
IEnergyInterfaceTile energy = (IEnergyInterfaceTile) tile;
if (PowerSystem.getDisplayPower() != PowerSystem.EnergySystem.EU) {
probeInfo.progress((int) energy.getEnergy() * RebornCoreConfig.euPerFU, (int) energy.getMaxPower() * RebornCoreConfig.euPerFU, euStyle);
} else {
probeInfo.progress((int) energy.getEnergy(), (int) energy.getMaxPower(), euStyle);
}
}
if (tile instanceof TileLegacyMachineBase && methodHandle_addStacks != null) {
TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) tile;
if (legacyMachineBase.getInventoryForTile().isPresent()) {
if (player.isSneaking()) {
probeInfo.text(I18n.translateToLocal("techreborn.tooltip.inventory"));
}
Inventory inventory = legacyMachineBase.getInventoryForTile().get();
if (!inventory.isEmpty()) {
List<ItemStack> stacks = Arrays.stream(inventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
try {
methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
if (!legacyMachineBase.upgradeInventory.isEmpty() && player.isSneaking()) {
probeInfo.horizontal();
probeInfo.text(I18n.translateToLocal("techreborn.tooltip.upgrades"));
List<ItemStack> stacks = Arrays.stream(legacyMachineBase.upgradeInventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
try {
methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
}
use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.
the class PacketIOSave method processData.
@Override
public void processData(PacketIOSave message, MessageContext context) {
TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) context.getServerHandler().player.world.getTileEntity(pos);
SlotConfiguration.SlotConfigHolder holder = legacyMachineBase.slotConfiguration.getSlotDetails(slotID);
if (holder == null) {
return;
}
holder.setInput(input);
holder.setOutput(output);
holder.setfilter(filter);
// Syncs back to the client
PacketSlotSync packetSlotSync = new PacketSlotSync(pos, legacyMachineBase.slotConfiguration);
NetworkManager.sendToAll(packetSlotSync);
}
use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.
the class PacketSlotSync method processData.
@Override
public void processData(PacketSlotSync message, MessageContext context) {
if (!RebornCore.proxy.getClientWorld().isBlockLoaded(pos, false)) {
return;
}
TileLegacyMachineBase machineBase = (TileLegacyMachineBase) RebornCore.proxy.getClientWorld().getTileEntity(pos);
if (machineBase == null || machineBase.slotConfiguration == null || slotConfig == null || slotConfig.getSlotDetails() == null) {
RebornCore.logHelper.error("Failed to sync slot data to " + pos);
}
Minecraft.getMinecraft().addScheduledTask(() -> slotConfig.getSlotDetails().forEach(slotConfigHolder -> machineBase.slotConfiguration.updateSlotDetails(slotConfigHolder)));
}
use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.
the class PacketSlotSave method processData.
@Override
public void processData(PacketSlotSave message, MessageContext context) {
TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) context.getServerHandler().player.world.getTileEntity(pos);
legacyMachineBase.slotConfiguration.getSlotDetails(slotConfig.getSlotID()).updateSlotConfig(slotConfig);
legacyMachineBase.markDirty();
PacketSlotSync packetSlotSync = new PacketSlotSync(pos, legacyMachineBase.slotConfiguration);
NetworkManager.sendToWorld(packetSlotSync, legacyMachineBase.getWorld());
}
Aggregations