Move gui code to reborn core
This commit is contained in:
parent
b399e211fa
commit
f91493dbc5
81 changed files with 106 additions and 3536 deletions
|
@ -27,9 +27,10 @@ package techreborn.client.gui;
|
|||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.gui.widget.GuiButtonUpDown;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
|
||||
import techreborn.packets.PacketAesu;
|
||||
import techreborn.tiles.storage.TileAdjustableSU;
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileAlloySmelter;
|
||||
|
||||
public class GuiAlloySmelter extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileAssemblingMachine;
|
||||
|
||||
public class GuiAssemblingMachine extends GuiBase {
|
||||
|
|
|
@ -32,6 +32,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.packets.PacketAutoCraftingTableLock;
|
||||
import techreborn.tiles.tier1.TileAutoCraftingTable;
|
||||
|
|
|
@ -1,335 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import techreborn.client.gui.slot.GuiFluidConfiguration;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.items.DynamicCell;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
public class GuiBase extends GuiContainer {
|
||||
|
||||
public int xSize = 176;
|
||||
public int ySize = 176;
|
||||
public TRBuilder builder = new TRBuilder();
|
||||
public TileEntity tile;
|
||||
public BuiltContainer container;
|
||||
public static SlotConfigType slotConfigType = SlotConfigType.NONE;
|
||||
|
||||
public boolean upgrades;
|
||||
|
||||
public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) {
|
||||
super(container);
|
||||
this.tile = tile;
|
||||
this.container = container;
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
}
|
||||
|
||||
protected void drawSlot(int x, int y, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawSlot(this, x - 1, y - 1);
|
||||
}
|
||||
|
||||
protected void drawScrapSlot(int x, int y, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawScrapSlot(this, x - 1, y - 1);
|
||||
}
|
||||
|
||||
protected void drawOutputSlotBar(int x, int y, int count, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawOutputSlotBar(this, x - 4, y - 4, count);
|
||||
}
|
||||
|
||||
protected void drawArmourSlots(int x, int y, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawSlot(this, x - 1, y - 1);
|
||||
builder.drawSlot(this, x - 1, y - 1 + 18);
|
||||
builder.drawSlot(this, x - 1, y - 1 + 18 + 18);
|
||||
builder.drawSlot(this, x - 1, y - 1 + 18 + 18 + 18);
|
||||
}
|
||||
|
||||
protected void drawOutputSlot(int x, int y, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawOutputSlot(this, x - 5, y - 5);
|
||||
}
|
||||
|
||||
protected void drawSelectedStack(int x, int y, Layer layer) {
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
x += guiLeft;
|
||||
y += guiTop;
|
||||
}
|
||||
builder.drawSelectedStack(this, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
GuiSlotConfiguration.init(this);
|
||||
if(getMachine().getTank() != null && getMachine().showTankConfig()){
|
||||
GuiFluidConfiguration.init(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
builder.drawDefaultBackground(this, guiLeft, guiTop, xSize, ySize);
|
||||
if (drawPlayerSlots()) {
|
||||
builder.drawPlayerSlots(this, guiLeft + xSize / 2, guiTop + 93, true);
|
||||
}
|
||||
if (tryAddUpgrades() && tile instanceof IUpgradeable) {
|
||||
IUpgradeable upgradeable = (IUpgradeable) tile;
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
builder.drawUpgrades(this, upgradeable, guiLeft, guiTop);
|
||||
upgrades = true;
|
||||
}
|
||||
}
|
||||
if(getMachine().hasSlotConfig()){
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades, new ItemStack(ModItems.WRENCH));
|
||||
}
|
||||
if(getMachine().showTankConfig()){
|
||||
builder.drawSlotTab(this, guiLeft, guiTop + 27, mouseX, mouseY, upgrades, DynamicCell.getCellWithFluid(FluidRegistry.LAVA));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean drawPlayerSlots() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean tryAddUpgrades() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.buttonList.clear();
|
||||
drawTitle();
|
||||
if(slotConfigType == SlotConfigType.ITEMS && getMachine().hasSlotConfig()){
|
||||
GuiSlotConfiguration.draw(this, mouseX, mouseY);
|
||||
}
|
||||
|
||||
if(slotConfigType == SlotConfigType.FLUIDS && getMachine().showTankConfig()){
|
||||
GuiFluidConfiguration.draw(this, mouseX, mouseY);
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
if (builder.isInRect(guiLeft - 19, guiTop + 92 - offset, 12, 12, mouseX, mouseY) && getMachine().hasSlotConfig()) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Configure slots");
|
||||
GuiUtils.drawHoveringText(list, mouseX - guiLeft , mouseY - guiTop , width, height, -1, mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
if (builder.isInRect(guiLeft - 19, guiTop + 92 - offset + 27, 12, 12, mouseX, mouseY) && getMachine().hasSlotConfig()) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Configure Fluids");
|
||||
GuiUtils.drawHoveringText(list, mouseX - guiLeft , mouseY - guiTop , width, height, -1, mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
protected void drawTitle() {
|
||||
drawCentredString(I18n.format(tile.getBlockType().getUnlocalizedName() + ".name"), 6, 4210752, Layer.FOREGROUND);
|
||||
}
|
||||
|
||||
protected void drawCentredString(String string, int y, int colour, Layer layer) {
|
||||
drawString(string, (xSize / 2 - mc.fontRenderer.getStringWidth(string) / 2), y, colour, layer);
|
||||
}
|
||||
|
||||
protected void drawCentredString(String string, int y, int colour, int modifier, Layer layer) {
|
||||
drawString(string, (xSize / 2 - (mc.fontRenderer.getStringWidth(string)) / 2) + modifier, y, colour, layer);
|
||||
}
|
||||
|
||||
protected void drawString(String string, int x, int y, int colour, Layer layer) {
|
||||
int factorX = 0;
|
||||
int factorY = 0;
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
factorX = guiLeft;
|
||||
factorY = guiTop;
|
||||
}
|
||||
mc.fontRenderer.drawString(string, x + factorX, y + factorY, colour);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
public void addPowerButton(int x, int y, int id, Layer layer) {
|
||||
int factorX = 0;
|
||||
int factorY = 0;
|
||||
if (layer == Layer.BACKGROUND) {
|
||||
factorX = guiLeft;
|
||||
factorY = guiTop;
|
||||
}
|
||||
buttonList.add(new GuiButtonPowerBar(id, x + factorX, y + factorY, this, layer));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(slotConfigType == SlotConfigType.ITEMS && getMachine().hasSlotConfig()){
|
||||
if(GuiSlotConfiguration.mouseClicked(mouseX, mouseY, mouseButton, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.FLUIDS && getMachine().showTankConfig()){
|
||||
if(GuiFluidConfiguration.mouseClicked(mouseX, mouseY, mouseButton, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if(slotConfigType == SlotConfigType.ITEMS && getMachine().hasSlotConfig()){
|
||||
GuiSlotConfiguration.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, this);
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.FLUIDS && getMachine().showTankConfig()){
|
||||
GuiFluidConfiguration.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, this);
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
int offset = 0;
|
||||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
if(isPointInRegion(-26, 84 - offset, 30, 30, mouseX, mouseY) && getMachine().hasSlotConfig()){
|
||||
if(slotConfigType != SlotConfigType.ITEMS){
|
||||
slotConfigType = SlotConfigType.ITEMS;
|
||||
} else {
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.ITEMS){
|
||||
GuiSlotConfiguration.reset();
|
||||
}
|
||||
}
|
||||
if(isPointInRegion(-26, 84 - offset + 27, 30, 30, mouseX, mouseY) && getMachine().hasSlotConfig()){
|
||||
if(slotConfigType != SlotConfigType.FLUIDS){
|
||||
slotConfigType = SlotConfigType.FLUIDS;
|
||||
} else {
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
}
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.ITEMS && getMachine().hasSlotConfig()){
|
||||
if(GuiSlotConfiguration.mouseReleased(mouseX, mouseY, state, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.FLUIDS && getMachine().showTankConfig()){
|
||||
if(GuiFluidConfiguration.mouseReleased(mouseX, mouseY, state, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if(slotConfigType == SlotConfigType.ITEMS){
|
||||
if(isCtrlKeyDown() && keyCode == Keyboard.KEY_C){
|
||||
GuiSlotConfiguration.copyToClipboard();
|
||||
return;
|
||||
} else if(isCtrlKeyDown() && keyCode == Keyboard.KEY_V){
|
||||
GuiSlotConfiguration.pasteFromClipboard();
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
public boolean isPointInRect(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY) {
|
||||
return super.isPointInRegion(rectX, rectY, rectWidth, rectHeight, pointX, pointY);
|
||||
}
|
||||
|
||||
public TileLegacyMachineBase getMachine(){
|
||||
return (TileLegacyMachineBase) tile;
|
||||
}
|
||||
|
||||
|
||||
public enum Layer {
|
||||
BACKGROUND, FOREGROUND
|
||||
}
|
||||
|
||||
public enum SlotConfigType{
|
||||
NONE,
|
||||
ITEMS,
|
||||
FLUIDS
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.tiles.storage.TileLowVoltageSU;
|
||||
|
||||
|
|
|
@ -30,12 +30,14 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileIndustrialBlastFurnace;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.TileIndustrialCentrifuge;
|
||||
|
||||
public class GuiCentrifuge extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.tiles.TileChargeOMat;
|
||||
|
||||
public class GuiChargeBench extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileChemicalReactor;
|
||||
|
||||
public class GuiChemicalReactor extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileCompressor;
|
||||
|
||||
public class GuiCompressor extends GuiBase {
|
||||
|
|
|
@ -27,6 +27,8 @@ package techreborn.client.gui;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.generator.TileDieselGenerator;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.tiles.TileDigitalChest;
|
||||
|
||||
public class GuiDigitalChest extends GuiBase {
|
||||
|
|
|
@ -30,13 +30,15 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileDistillationTower;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileElectricFurnace;
|
||||
|
||||
public class GuiElectricFurnace extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileExtractor;
|
||||
|
||||
public class GuiExtractor extends GuiBase {
|
||||
|
|
|
@ -29,13 +29,15 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileFluidReplicator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -29,17 +29,19 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import techreborn.client.gui.widget.GuiButtonUpDown;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.packets.PacketFusionControlSize;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
|
||||
|
||||
import java.awt.*;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.generator.TileGasTurbine;
|
||||
|
||||
public class GuiGasTurbine extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.tiles.generator.TileSolidFuelGenerator;
|
||||
|
||||
public class GuiGenerator extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileGrinder;
|
||||
|
||||
public class GuiGrinder extends GuiBase {
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.tiles.idsu.TileInterdimensionalSU;
|
||||
|
||||
|
|
|
@ -29,13 +29,15 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileImplosionCompressor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileIndustrialElectrolyzer;
|
||||
|
||||
public class GuiIndustrialElectrolyzer extends GuiBase {
|
||||
|
|
|
@ -30,13 +30,15 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileIndustrialGrinder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -30,13 +30,15 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileIndustrialSawmill;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.client.resources.I18n;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.tiles.tier0.TileIronFurnace;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.tiles.lesu.TileLapotronicSU;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.tiles.storage.TileMediumVoltageSU;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.tiles.storage.TileHighVoltageSU;
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.TileMatterFabricator;
|
||||
|
||||
public class GuiMatterFabricator extends GuiBase {
|
||||
|
|
|
@ -27,6 +27,8 @@ package techreborn.client.gui;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.generator.TilePlasmaGenerator;
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
|
||||
public class GuiQuantumChest extends GuiBase {
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import techreborn.tiles.TileQuantumTank;
|
||||
|
||||
public class GuiQuantumTank extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileRecycler;
|
||||
|
||||
public class GuiRecycler extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.packets.PacketRollingMachineLock;
|
||||
import techreborn.tiles.tier1.TileRollingMachine;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.tier1.TileScrapboxinator;
|
||||
|
||||
public class GuiScrapboxinator extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.generator.TileSemiFluidGenerator;
|
||||
|
||||
public class GuiSemifluidGenerator extends GuiBase {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.tiles.generator.TileThermalGenerator;
|
||||
|
||||
public class GuiThermalGenerator extends GuiBase {
|
||||
|
|
|
@ -28,13 +28,15 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.ClientProxy;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileVacuumFreezer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -1,531 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.client.guibuilder.GuiBuilder;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.item.ItemStack.EMPTY;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
public class TRBuilder extends GuiBuilder {
|
||||
public static final ResourceLocation GUI_SHEET = new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":" + "textures/gui/gui_sheet.png");
|
||||
|
||||
public TRBuilder() {
|
||||
super(GUI_SHEET);
|
||||
}
|
||||
|
||||
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY, int buttonID, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
|
||||
gui.drawTexturedModalRect(x, y, PowerSystem.getDisplayPower().xBar - 15, PowerSystem.getDisplayPower().yBar - 1, 14, 50);
|
||||
|
||||
int draw = (int) ((double) energyStored / (double) maxEnergyStored * (48));
|
||||
if (energyStored > maxEnergyStored) {
|
||||
draw = (int) ((double) maxEnergyStored / (double) maxEnergyStored * (48));
|
||||
}
|
||||
gui.drawTexturedModalRect(x + 1, y + 49 - draw, PowerSystem.getDisplayPower().xBar, 48 + PowerSystem.getDisplayPower().yBar - draw, 12, draw);
|
||||
int percentage = percentage(maxEnergyStored, energyStored);
|
||||
if (isInRect(x + 1, y + 1, 11, 48, mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
TextFormatting powerColour = TextFormatting.GOLD;
|
||||
list.add(powerColour + PowerSystem.getLocaliszedPowerFormattedNoSuffix(energyStored) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxEnergyStored) + " " + PowerSystem.getDisplayPower().abbreviation);
|
||||
list.add(StringUtils.getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Charged");
|
||||
if(gui.tile instanceof TilePowerAcceptor && GuiScreen.isShiftKeyDown()){
|
||||
((TilePowerAcceptor) gui.tile).addInfo(list, true);
|
||||
list.add("");
|
||||
list.add(TextFormatting.BLUE + "Click to change display unit");
|
||||
} else {
|
||||
list.add("");
|
||||
list.add(TextFormatting.BLUE + "Shift" + TextFormatting.GRAY + " for more info");
|
||||
}
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
gui.addPowerButton(x, y, buttonID, layer);
|
||||
}
|
||||
|
||||
public void drawProgressBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, direction.x, direction.y, direction.width, direction.height);
|
||||
int j = (int) ((double) progress / (double) maxProgress * 16);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
||||
switch (direction) {
|
||||
case RIGHT:
|
||||
gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, j, 10);
|
||||
break;
|
||||
case LEFT:
|
||||
gui.drawTexturedModalRect(x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
|
||||
break;
|
||||
case UP:
|
||||
gui.drawTexturedModalRect(x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
|
||||
break;
|
||||
case DOWN:
|
||||
gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, 10, j);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) {
|
||||
int percentage = percentage(maxProgress, progress);
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(StringUtils.getPercentageColour(percentage) + "" + percentage + "%");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTank(GuiBase gui, int x, int y, int mouseX, int mouseY, FluidStack fluid, int maxCapacity, boolean isTankEmpty, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
int percentage = 0;
|
||||
int amount = 0;
|
||||
boolean empty = true;
|
||||
if (!isTankEmpty) {
|
||||
amount = fluid.amount;
|
||||
percentage = percentage(maxCapacity, amount);
|
||||
empty = false;
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 228, 18, 22, 56);
|
||||
if (!empty)
|
||||
drawFluid(gui, fluid, x + 4, y + 4, 14, 48, maxCapacity);
|
||||
gui.drawTexturedModalRect(x + 3, y + 3, 231, 74, 16, 50);
|
||||
|
||||
if (isInRect(x, y, 22, 56, mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (empty)
|
||||
list.add(TextFormatting.GOLD + "Empty Tank");
|
||||
else
|
||||
list.add(TextFormatting.GOLD + "" + amount + "mB/" + maxCapacity + "mB " + fluid.getLocalizedName());
|
||||
list.add(StringUtils.getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Full");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawFluid(GuiBase gui, FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
|
||||
gui.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
y += height;
|
||||
final ResourceLocation still = fluid.getFluid().getStill(fluid);
|
||||
final TextureAtlasSprite sprite = gui.mc.getTextureMapBlocks().getAtlasSprite(still.toString());
|
||||
|
||||
final int drawHeight = (int) (fluid.amount / (maxCapacity * 1F) * height);
|
||||
final int iconHeight = sprite.getIconHeight();
|
||||
int offsetHeight = drawHeight;
|
||||
|
||||
int iteration = 0;
|
||||
while (offsetHeight != 0) {
|
||||
final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
|
||||
gui.drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
|
||||
offsetHeight -= curHeight;
|
||||
iteration++;
|
||||
if (iteration > 50)
|
||||
break;
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
}
|
||||
|
||||
public void drawJEIButton(GuiBase gui, int x, int y, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (Loader.isModLoaded("jei")) {
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 184, 70, 20, 12);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLockButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer, boolean locked) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 204, 70 + (locked ? 12 : 0) , 20, 12);
|
||||
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if(locked){
|
||||
list.add("Unlock items");
|
||||
} else {
|
||||
list.add("Lock Items");
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, 80, gui.mc.fontRenderer);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawHologramButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
gui.drawTexturedModalRect(x, y, 184, 94, 20, 12);
|
||||
} else {
|
||||
gui.drawTexturedModalRect(x, y, 184, 106, 20, 12);
|
||||
}
|
||||
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Toggle Multiblock Hologram");
|
||||
GlStateManager.pushMatrix();
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawUpDownButtons(GuiBase gui, int x, int y, GuiBase.Layer layer){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 150, 70, 12, 12);
|
||||
gui.drawTexturedModalRect(x + 12, y, 150, 82, 12, 12);
|
||||
gui.drawTexturedModalRect(x + 24, y, 150, 94, 12, 12);
|
||||
gui.drawTexturedModalRect(x + 36, y, 150, 106, 12, 12);
|
||||
}
|
||||
|
||||
public void drawUpDownButtonsSmall(GuiBase gui, int x, int y, GuiBase.Layer layer){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
//gui.drawTexturedModalRect(x, y, 150, 70, 12, 12);
|
||||
gui.drawTexturedModalRect(x + 12, y, 150, 82, 12, 12);
|
||||
gui.drawTexturedModalRect(x + 24, y, 150, 94, 12, 12);
|
||||
//gui.drawTexturedModalRect(x + 36, y, 150, 106, 12, 12);
|
||||
}
|
||||
|
||||
public void drawEnergyOutput(GuiBase gui, int right, int top, int maxOutput, GuiBase.Layer layer){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
String text = PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxOutput) + " "
|
||||
+ PowerSystem.getDisplayPower().abbreviation + "/t";
|
||||
int width = gui.mc.fontRenderer.getStringWidth(text);
|
||||
gui.drawString(text, right - 17 - width, top + 5, 0, layer);
|
||||
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
right += gui.getGuiLeft();
|
||||
top += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(right - 16, top, 162, 101, 16, 17);
|
||||
}
|
||||
|
||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
if (!suffix.equals("")) {
|
||||
suffix = " " + suffix;
|
||||
}
|
||||
gui.drawTexturedModalRect(x, y, 0, 218, 114, 18);
|
||||
int j = (int) ((double) value / (double) max * 106);
|
||||
if (j < 0)
|
||||
j = 0;
|
||||
gui.drawTexturedModalRect(x + 4, y + 4, 0, 236, j, 10);
|
||||
gui.drawCentredString(value + suffix, y + 5, 0xFFFFFF, layer);
|
||||
if (isInRect(x, y, 114, 18, mouseX, mouseY)) {
|
||||
int percentage = percentage(max, value);
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("" + TextFormatting.GOLD + value + "/" + max + suffix);
|
||||
list.add(StringUtils.getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Full");
|
||||
|
||||
if (value > max) {
|
||||
list.add(TextFormatting.GRAY + "Yo this is storing more than it should be able to");
|
||||
list.add(TextFormatting.GRAY + "prolly a bug");
|
||||
list.add(TextFormatting.GRAY + "pls report and tell how tf you did this");
|
||||
}
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawBigHeatBar(GuiBase gui, int x, int y, int value, int max, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 0, 218, 114, 18);
|
||||
if (value != 0) {
|
||||
int j = (int) ((double) value / (double) max * 106);
|
||||
if (j < 0)
|
||||
j = 0;
|
||||
gui.drawTexturedModalRect(x + 4, y + 4, 0, 246, j, 10);
|
||||
gui.drawCentredString(value + " Heat", y + 5, 0xFFFFFF, layer);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void drawMultiblockMissingBar(GuiBase gui, GuiBase.Layer layer) {
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
int x = 0;
|
||||
int y = 4;
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.colorMask(true, true, true, false);
|
||||
GuiUtils.drawGradientRect(0, x, y, x + 176, y + 20, 0x000000, 0xC0000000);
|
||||
GuiUtils.drawGradientRect(0, x, y + 20, x + 176, y + 20 + 48, 0xC0000000, 0xC0000000);
|
||||
GuiUtils.drawGradientRect(0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
|
||||
GlStateManager.colorMask(true, true, true, true);
|
||||
GlStateManager.enableDepth();
|
||||
gui.drawCentredString(I18n.format("techreborn.message.missingmultiblock"), 43, 0xFFFFFF, layer);
|
||||
}
|
||||
|
||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
drawBigBlueBar(gui, x, y, value, max, mouseX, mouseY, "", layer);
|
||||
}
|
||||
|
||||
public void drawSelectedStack(GuiBase gui, int x, int y) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x - 4, y - 4, 202, 44, 24, 24);
|
||||
}
|
||||
|
||||
public void drawBurnBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 171, 84, 13, 13);
|
||||
int j = 13 - (int) ((double) progress / (double) maxProgress * 13);
|
||||
if (j > 0) {
|
||||
gui.drawTexturedModalRect(x, y + j, 171, 70 + j, 13, 13 - j);
|
||||
|
||||
}
|
||||
if (isInRect(x, y, 12, 12, mouseX, mouseY)) {
|
||||
int percentage = percentage(maxProgress, progress);
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(StringUtils.getPercentageColour(percentage) + "" + percentage + "%");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSlot(GuiScreen gui, int posX, int posY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX, posY, 150, 0, 18, 18);
|
||||
}
|
||||
|
||||
public void drawUpgrades(GuiScreen gui, IUpgradeable upgradeable, int posX, int posY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX - 27, posY + 4, 126, 151, 30, 87);
|
||||
}
|
||||
|
||||
public void drawSlotTab(GuiScreen gui, int posX, int posY, int mouseX, int mouseY, boolean upgrades, ItemStack stack){
|
||||
int offset = -1;
|
||||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX - 26, posY + 84 - offset, 157, 149, 30, 30);
|
||||
renderItemStack(stack, posX - 19, posY + 92 - offset);
|
||||
}
|
||||
|
||||
public void renderItemStack(ItemStack stack, int x, int y) {
|
||||
if (stack != EMPTY) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScrapSlot(GuiScreen gui, int posX, int posY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX, posY, 150, 0, 18, 18);
|
||||
}
|
||||
|
||||
public void drawOutputSlotBar(GuiScreen gui, int posX, int posY, int count) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
for (int i = 1; i <= count; i++) {
|
||||
if (i == 1) {
|
||||
gui.drawTexturedModalRect(posX, posY, 125 + 39, 218, 22, 26);
|
||||
posX += 22;
|
||||
if (1 == count) {
|
||||
gui.drawTexturedModalRect(posX, posY, 147 + 39, 218, 4, 26);
|
||||
}
|
||||
} else if (i != 1 && i != count) {
|
||||
gui.drawTexturedModalRect(posX, posY, 127 + 39, 218, 20, 26);
|
||||
posX += 20;
|
||||
} else if (i == count) {
|
||||
gui.drawTexturedModalRect(posX, posY, 127 + 39, 218, 24, 26);
|
||||
posX += 24;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOutputSlot(GuiScreen gui, int posX, int posY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX, posY, 150, 18, 26, 26);
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * scale);
|
||||
}
|
||||
|
||||
public int percentage(int MaxValue, int CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
|
||||
public enum ProgressDirection {
|
||||
RIGHT(84, 151, 100, 151, 16, 10), LEFT(100, 161, 84, 161, 16, 10), DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16);
|
||||
public int x;
|
||||
public int y;
|
||||
public int xActive;
|
||||
public int yActive;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
ProgressDirection(int x, int y, int xActive, int yActive, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.xActive = xActive;
|
||||
this.yActive = yActive;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.elements.ConfigFluidElement;
|
||||
import techreborn.client.gui.slot.elements.ElementBase;
|
||||
import techreborn.client.gui.slot.elements.SlotType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiFluidConfiguration {
|
||||
|
||||
static ConfigFluidElement fluidConfigElement;
|
||||
|
||||
public static void init(GuiBase guiBase) {
|
||||
fluidConfigElement = new ConfigFluidElement(guiBase.getMachine().getTank(), SlotType.NORMAL, 35 - guiBase.guiLeft + 50, 35 - guiBase.guiTop - 25, guiBase);
|
||||
}
|
||||
|
||||
public static void draw(GuiBase guiBase, int mouseX, int mouseY) {
|
||||
fluidConfigElement.draw(guiBase);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void keyboardEvent(GuiScreenEvent.KeyboardInputEvent event) {
|
||||
if (GuiBase.slotConfigType == GuiBase.SlotConfigType.FLUIDS && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
|
||||
GuiBase.slotConfigType = GuiBase.SlotConfigType.NONE;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ConfigFluidElement> getVisibleElements() {
|
||||
return Collections.singletonList(fluidConfigElement);
|
||||
}
|
||||
|
||||
public static boolean mouseClicked(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) throws IOException {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigFluidElement configFluidElement : getVisibleElements()) {
|
||||
for (ElementBase element : configFluidElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isPressing = true;
|
||||
boolean action = element.onStartPress(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isPressing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isPressing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return !getVisibleElements().isEmpty();
|
||||
}
|
||||
|
||||
public static void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick, GuiBase guiBase) {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigFluidElement configFluidElement : getVisibleElements()) {
|
||||
for (ElementBase element : configFluidElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isDragging = true;
|
||||
boolean action = element.onDrag(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isDragging = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean mouseReleased(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) {
|
||||
boolean clicked = false;
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigFluidElement configFluidElement : getVisibleElements()) {
|
||||
if (configFluidElement.isInRect(guiBase, configFluidElement.x, configFluidElement.y, configFluidElement.getWidth(guiBase.getMachine()), configFluidElement.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
clicked = true;
|
||||
}
|
||||
for (ElementBase element : Lists.reverse(configFluidElement.elements)) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isReleasing = true;
|
||||
boolean action = element.onRelease(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isReleasing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
clicked = true;
|
||||
break;
|
||||
} else {
|
||||
element.isReleasing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TileLegacyMachineBase getMachine() {
|
||||
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiBase)) {
|
||||
return null;
|
||||
}
|
||||
GuiBase base = (GuiBase) Minecraft.getMinecraft().currentScreen;
|
||||
if (!(base.tile instanceof TileLegacyMachineBase)) {
|
||||
return null;
|
||||
}
|
||||
TileLegacyMachineBase machineBase = (TileLegacyMachineBase) base.tile;
|
||||
return machineBase;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,255 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.network.packet.PacketConfigSave;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.elements.ConfigSlotElement;
|
||||
import techreborn.client.gui.slot.elements.ElementBase;
|
||||
import techreborn.client.gui.slot.elements.SlotType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuiSlotConfiguration {
|
||||
|
||||
static HashMap<Integer, ConfigSlotElement> slotElementMap = new HashMap<>();
|
||||
|
||||
public static int slectedSlot = 0;
|
||||
|
||||
public static void reset() {
|
||||
slectedSlot = -1;
|
||||
}
|
||||
|
||||
public static void init(GuiBase guiBase) {
|
||||
reset();
|
||||
slotElementMap.clear();
|
||||
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
ConfigSlotElement slotElement = new ConfigSlotElement(guiBase.getMachine(), slot.getSlotIndex(), SlotType.NORMAL, slot.xPos - guiBase.guiLeft + 50, slot.yPos - guiBase.guiTop - 25, guiBase);
|
||||
slotElementMap.put(slot.getSlotIndex(), slotElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void draw(GuiBase guiBase, int mouseX, int mouseY) {
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
GlStateManager.color(255, 0, 0);
|
||||
Color color = new Color(255, 0, 0, 128);
|
||||
GuiUtil.drawGradientRect(slot.xPos - 1, slot.yPos - 1, 18, 18, color.getRGB(), color.getRGB());
|
||||
GlStateManager.color(255, 255, 255);
|
||||
}
|
||||
|
||||
if (slectedSlot != -1) {
|
||||
slotElementMap.get(slectedSlot).draw(guiBase);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ConfigSlotElement> getVisibleElements() {
|
||||
if(slectedSlot == -1){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return slotElementMap.values().stream()
|
||||
.filter(configSlotElement -> configSlotElement.getId() == slectedSlot)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//Allows closing of the widget with the escape key
|
||||
@SubscribeEvent
|
||||
public static void keyboardEvent(GuiScreenEvent.KeyboardInputEvent event){
|
||||
if(!getVisibleElements().isEmpty() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE){
|
||||
slectedSlot = -1;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyToClipboard(){
|
||||
TileLegacyMachineBase machine = getMachine();
|
||||
if(machine == null || machine.slotConfiguration == null){
|
||||
return;
|
||||
}
|
||||
String json = machine.slotConfiguration.toJson(machine.getClass().getCanonicalName());
|
||||
GuiScreen.setClipboardString(json);
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Slot configuration copyied to clipboard"));
|
||||
}
|
||||
|
||||
public static void pasteFromClipboard(){
|
||||
TileLegacyMachineBase machine = getMachine();
|
||||
if(machine == null || machine.slotConfiguration == null){
|
||||
return;
|
||||
}
|
||||
String json = GuiScreen.getClipboardString();
|
||||
try {
|
||||
machine.slotConfiguration.readJson(json, machine.getClass().getCanonicalName());
|
||||
NetworkManager.sendToServer(new PacketConfigSave(machine.getPos(), machine.slotConfiguration));
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Slot configuration loaded from clipboard"));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TileLegacyMachineBase getMachine(){
|
||||
if(!(Minecraft.getMinecraft().currentScreen instanceof GuiBase)){
|
||||
return null;
|
||||
}
|
||||
GuiBase base = (GuiBase) Minecraft.getMinecraft().currentScreen;
|
||||
if(!(base.tile instanceof TileLegacyMachineBase)){
|
||||
return null;
|
||||
}
|
||||
TileLegacyMachineBase machineBase = (TileLegacyMachineBase) base.tile;
|
||||
return machineBase;
|
||||
}
|
||||
|
||||
public static boolean mouseClicked(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) throws IOException {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
for (ElementBase element : configSlotElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isPressing = true;
|
||||
boolean action = element.onStartPress(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isPressing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isPressing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BuiltContainer container = guiBase.container;
|
||||
|
||||
if(getVisibleElements().isEmpty()) {
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
if (guiBase.isPointInRect(slot.xPos, slot.yPos, 18, 18, mouseX, mouseY)) {
|
||||
slectedSlot = slot.getSlotIndex();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !getVisibleElements().isEmpty();
|
||||
}
|
||||
|
||||
public static void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick, GuiBase guiBase) {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
for (ElementBase element : configSlotElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isDragging = true;
|
||||
boolean action = element.onDrag(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isDragging = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean mouseReleased(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) {
|
||||
boolean clicked = false;
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
if (configSlotElement.isInRect(guiBase, configSlotElement.x, configSlotElement.y, configSlotElement.getWidth(guiBase.getMachine()), configSlotElement.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
clicked = true;
|
||||
}
|
||||
for (ElementBase element : Lists.reverse(configSlotElement.elements)) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isReleasing = true;
|
||||
boolean action = element.onRelease(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isReleasing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
clicked = true;
|
||||
break;
|
||||
} else {
|
||||
element.isReleasing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
||||
public static List<Rectangle> getExtraSpace(GuiBase guiBase){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.ITEMS || slectedSlot == -1){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Rectangle> list = new ArrayList<>();
|
||||
ConfigSlotElement slotElement = slotElementMap.get(slectedSlot);
|
||||
|
||||
if(slotElement == null || guiBase == null){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
//I have no idea why this works, but it does. pls fix if you know how.
|
||||
list.add(new Rectangle(slotElement.adjustX(guiBase, slotElement.getX()) + guiBase.getGuiLeft() - 25, slotElement.adjustY(guiBase, 0) -10, slotElement.getWidth() - 5, slotElement.getHeight() + 15));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
public class ButtonElement extends ElementBase {
|
||||
@SuppressWarnings("unused")
|
||||
private Sprite.Button buttonSprite;
|
||||
|
||||
public ButtonElement(int x, int y, Sprite.Button buttonSprite) {
|
||||
super(x, y, buttonSprite.getNormal());
|
||||
this.buttonSprite = buttonSprite;
|
||||
this.addUpdateAction((gui, element) -> {
|
||||
if (isHovering) {
|
||||
element.container.setSprite(0, buttonSprite.getHovered());
|
||||
} else {
|
||||
element.container.setSprite(0, buttonSprite.getNormal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CheckBoxElement extends ElementBase {
|
||||
public String label, type;
|
||||
public int labelColor, slotID;
|
||||
public TileLegacyMachineBase machineBase;
|
||||
Predicate<CheckBoxElement> ticked;
|
||||
|
||||
private Sprite.CheckBox checkBoxSprite;
|
||||
|
||||
public CheckBoxElement(String label, int labelColor, int x, int y, String type, int slotID, Sprite.CheckBox checkBoxSprite, TileLegacyMachineBase machineBase, Predicate<CheckBoxElement> ticked) {
|
||||
super(x, y, checkBoxSprite.getNormal());
|
||||
this.checkBoxSprite = checkBoxSprite;
|
||||
this.type = type;
|
||||
this.slotID = slotID;
|
||||
this.machineBase = machineBase;
|
||||
this.label = label;
|
||||
this.labelColor = labelColor;
|
||||
this.ticked = ticked;
|
||||
if (ticked.test(this)) {
|
||||
container.setSprite(0, checkBoxSprite.getTicked());
|
||||
} else {
|
||||
container.setSprite(0, checkBoxSprite.getNormal());
|
||||
}
|
||||
this.addPressAction((element, gui, provider, mouseX, mouseY) -> {
|
||||
if (ticked.test(this)) {
|
||||
element.container.setSprite(0, checkBoxSprite.getTicked());
|
||||
} else {
|
||||
element.container.setSprite(0, checkBoxSprite.getNormal());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
// super.draw(gui);
|
||||
ISprite sprite = checkBoxSprite.getNormal();
|
||||
if(ticked.test(this)){
|
||||
sprite = checkBoxSprite.getTicked();
|
||||
}
|
||||
drawSprite(gui, sprite, x, y );
|
||||
drawString(gui, label, x + checkBoxSprite.getNormal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.mc.fontRenderer.FONT_HEIGHT / 2)), labelColor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigFluidElement extends ElementBase {
|
||||
SlotType type;
|
||||
Tank tank;
|
||||
public List<ElementBase> elements = new ArrayList<>();
|
||||
boolean filter = false;
|
||||
|
||||
public ConfigFluidElement(Tank tank, SlotType type, int x, int y, GuiBase gui) {
|
||||
super(x, y, type.getButtonSprite());
|
||||
this.type = type;
|
||||
this.tank = tank;
|
||||
|
||||
FluidConfigPopupElement popupElement;
|
||||
|
||||
elements.add(popupElement = new FluidConfigPopupElement(x - 22, y - 22, this));
|
||||
elements.add(new ButtonElement(x + 37, y - 25, Sprite.EXIT_BUTTON).addReleaseAction((element, gui1, provider, mouseX, mouseY) -> {
|
||||
GuiBase.slotConfigType = GuiBase.SlotConfigType.NONE;
|
||||
return true;
|
||||
}));
|
||||
|
||||
elements.add(new CheckBoxElement("Pull In", 0xFFFFFFFF, x - 26, y + 42, "input", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
|
||||
checkBoxElement -> checkBoxElement.machineBase.fluidConfiguration.autoInput()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "input", gui12);
|
||||
return true;
|
||||
}));
|
||||
elements.add(new CheckBoxElement("Pump Out", 0xFFFFFFFF, x - 26, y + 57, "output", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
|
||||
checkBoxElement -> checkBoxElement.machineBase.fluidConfiguration.autoOutput()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13);
|
||||
return true;
|
||||
}));
|
||||
|
||||
setWidth(85);
|
||||
setHeight(105 + (filter ? 15 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
super.draw(gui);
|
||||
if (isHovering) {
|
||||
drawSprite(gui, type.getButtonHoverOverlay(), x, y);
|
||||
}
|
||||
elements.forEach(elementBase -> elementBase.draw(gui));
|
||||
}
|
||||
|
||||
public SlotType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigSlotElement extends ElementBase {
|
||||
SlotType type;
|
||||
IInventory inventory;
|
||||
int id;
|
||||
public List<ElementBase> elements = new ArrayList<>();
|
||||
boolean filter = false;
|
||||
|
||||
|
||||
public ConfigSlotElement(IInventory slotInventory, int slotId, SlotType type, int x, int y, GuiBase gui) {
|
||||
super(x, y, type.getButtonSprite());
|
||||
this.type = type;
|
||||
this.inventory = slotInventory;
|
||||
this.id = slotId;
|
||||
|
||||
SlotConfigPopupElement popupElement;
|
||||
|
||||
elements.add(popupElement = new SlotConfigPopupElement(this.id, x - 22, y - 22, this));
|
||||
elements.add(new ButtonElement(x + 37, y - 25, Sprite.EXIT_BUTTON).addReleaseAction((element, gui1, provider, mouseX, mouseY) -> {
|
||||
GuiSlotConfiguration.slectedSlot = -1;
|
||||
GuiBase.slotConfigType = GuiBase.SlotConfigType.NONE;
|
||||
return true;
|
||||
}));
|
||||
|
||||
elements.add(new CheckBoxElement("Auto Input", 0xFFFFFFFF, x - 26, y + 42, "input", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
|
||||
checkBoxElement -> checkBoxElement.machineBase.slotConfiguration.getSlotDetails(checkBoxElement.slotID).autoInput()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "input", gui12);
|
||||
return true;
|
||||
}));
|
||||
elements.add(new CheckBoxElement("Auto Output", 0xFFFFFFFF, x - 26, y + 57, "output", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
|
||||
checkBoxElement -> checkBoxElement.machineBase.slotConfiguration.getSlotDetails(checkBoxElement.slotID).autoOutput()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13);
|
||||
return true;
|
||||
}));
|
||||
|
||||
if(gui.getMachine() instanceof IRecipeCrafterProvider){
|
||||
RecipeCrafter recipeCrafter = ((IRecipeCrafterProvider) gui.getMachine()).getRecipeCrafter();
|
||||
if(Arrays.stream(recipeCrafter.inputSlots).anyMatch(value -> value == slotId)){
|
||||
elements.add(new CheckBoxElement("Filter Input", 0xFFFFFFFF, x - 26, y + 72, "filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
|
||||
checkBoxElement -> checkBoxElement.machineBase.slotConfiguration.getSlotDetails(checkBoxElement.slotID).filter()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "filter", gui13);
|
||||
return true;
|
||||
}));
|
||||
filter = true;
|
||||
popupElement.filter = true;
|
||||
}
|
||||
}
|
||||
setWidth(85);
|
||||
setHeight(105 + (filter ? 15 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
super.draw(gui);
|
||||
ItemStack stack = inventory.getStackInSlot(id);
|
||||
int xPos = x + 1 + gui.guiLeft;
|
||||
int yPos = y + 1 + gui.guiTop;
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
renderItem.renderItemAndEffectIntoGUI(gui.mc.player, stack, xPos, yPos);
|
||||
renderItem.renderItemOverlayIntoGUI(gui.mc.fontRenderer, stack, xPos, yPos, null);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
if (isHovering) {
|
||||
drawSprite(gui, type.getButtonHoverOverlay(), x, y);
|
||||
}
|
||||
elements.forEach(elementBase -> elementBase.draw(gui));
|
||||
}
|
||||
|
||||
public SlotType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
|
@ -1,384 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.client.guibuilder.GuiBuilder;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ElementBase {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public boolean isHovering = false;
|
||||
public boolean isDragging = false;
|
||||
public boolean isPressing = false;
|
||||
public boolean isReleasing = false;
|
||||
public boolean startPressLast = false;
|
||||
public boolean isHoveringLast = false;
|
||||
public boolean isDraggingLast = false;
|
||||
public boolean isPressingLast = false;
|
||||
public boolean isReleasingLast = false;
|
||||
public List<ElementBase.Action> hoverActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> dragActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> startPressActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> pressActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> releaseActions = new ArrayList<>();
|
||||
public SpriteContainer container;
|
||||
public List<UpdateAction> updateActions = new ArrayList<>();
|
||||
public List<UpdateAction> buttonUpdate = new ArrayList<>();
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public static final ResourceLocation MECH_ELEMENTS = new ResourceLocation(ModInfo.MOD_ID, "textures/gui/elements.png");
|
||||
|
||||
public ElementBase(int x, int y, SpriteContainer container) {
|
||||
this.container = container;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, ISprite... sprites) {
|
||||
this.container = new SpriteContainer();
|
||||
for (ISprite sprite : sprites) {
|
||||
container.addSprite(sprite);
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height) {
|
||||
this.container = new SpriteContainer();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height, SpriteContainer container) {
|
||||
this.container = container;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height, ISprite... sprites) {
|
||||
this.container = new SpriteContainer();
|
||||
for (ISprite sprite : sprites) {
|
||||
container.addSprite(sprite);
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public SpriteContainer getSpriteContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void adjustDimensions(TileLegacyMachineBase provider) {
|
||||
if (container.offsetSprites != null) {
|
||||
for (OffsetSprite offsetSprite : container.offsetSprites) {
|
||||
if (offsetSprite.getSprite().getSprite(provider).width + offsetSprite.getOffsetX(provider) > this.width) {
|
||||
this.width = offsetSprite.getSprite().getSprite(provider).width + offsetSprite.getOffsetX(provider);
|
||||
}
|
||||
if (offsetSprite.getSprite().getSprite(provider).height + offsetSprite.getOffsetY(provider) > this.height) {
|
||||
this.height = offsetSprite.getSprite().getSprite(provider).height + offsetSprite.getOffsetY(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(GuiBase gui) {
|
||||
for (OffsetSprite sprite : getSpriteContainer().offsetSprites) {
|
||||
drawSprite(gui, sprite.getSprite(), x + sprite.getOffsetX(gui.getMachine()), y + sprite.getOffsetY(gui.getMachine()));
|
||||
}
|
||||
}
|
||||
|
||||
public void renderUpdate(GuiBase gui) {
|
||||
isHoveringLast = isHovering;
|
||||
isPressingLast = isPressing;
|
||||
isDraggingLast = isDragging;
|
||||
isReleasingLast = isReleasing;
|
||||
}
|
||||
|
||||
public void update(GuiBase gui) {
|
||||
for (UpdateAction action : updateActions) {
|
||||
action.update(gui, this);
|
||||
}
|
||||
}
|
||||
|
||||
public ElementBase addUpdateAction(UpdateAction action) {
|
||||
updateActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase setWidth(int width) {
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase setHeight(int height) {
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public ElementBase setX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public ElementBase setY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth(TileLegacyMachineBase provider) {
|
||||
adjustDimensions(provider);
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight(TileLegacyMachineBase provider) {
|
||||
adjustDimensions(provider);
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public ElementBase addHoverAction(ElementBase.Action action) {
|
||||
this.hoverActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addDragAction(ElementBase.Action action) {
|
||||
this.dragActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addStartPressAction(ElementBase.Action action) {
|
||||
this.startPressActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addPressAction(ElementBase.Action action) {
|
||||
this.pressActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addReleaseAction(ElementBase.Action action) {
|
||||
this.releaseActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean onHover(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : hoverActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !hoverActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onDrag(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : dragActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !dragActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onStartPress(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : startPressActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !startPressActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onRelease(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : releaseActions) {
|
||||
if(action.execute(this, gui, provider, mouseX, mouseY)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isPressing) {
|
||||
for (ElementBase.Action action : pressActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
return !releaseActions.isEmpty() || !pressActions.isEmpty();
|
||||
}
|
||||
|
||||
public interface Action {
|
||||
boolean execute(ElementBase element, GuiBase gui, TileLegacyMachineBase provider, int mouseX, int mouseY);
|
||||
}
|
||||
|
||||
public interface UpdateAction {
|
||||
void update(GuiBase gui, ElementBase element);
|
||||
}
|
||||
|
||||
public void drawRect(GuiBase gui, int x, int y, int width, int height, int colour) {
|
||||
drawGradientRect(gui, x, y, width, height, colour, colour);
|
||||
}
|
||||
|
||||
/*
|
||||
Taken from Gui
|
||||
*/
|
||||
public void drawGradientRect(GuiBase gui, int x, int y, int width, int height, int startColor, int endColor) {
|
||||
x = adjustX(gui, x);
|
||||
y = adjustY(gui, y);
|
||||
|
||||
int left = x;
|
||||
int top = y;
|
||||
int right = x + width;
|
||||
int bottom = y + height;
|
||||
float f = (float) (startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (startColor & 255) / 255.0F;
|
||||
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder vertexbuffer = tessellator.getBuffer();
|
||||
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
vertexbuffer.pos((double) right, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
|
||||
vertexbuffer.pos((double) left, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
|
||||
vertexbuffer.pos((double) left, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
|
||||
vertexbuffer.pos((double) right, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public int adjustX(GuiBase gui, int x) {
|
||||
return gui.guiLeft + x;
|
||||
}
|
||||
|
||||
public int adjustY(GuiBase gui, int y) {
|
||||
return gui.guiTop + y;
|
||||
}
|
||||
|
||||
public boolean isInRect(GuiBase gui, int x, int y, int xSize, int ySize, int mouseX, int mouseY) {
|
||||
return gui.isPointInRect(x + gui.guiLeft, y + gui.guiTop, xSize, ySize, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void drawString(GuiBase gui, String string, int x, int y, int color) {
|
||||
x = adjustX(gui, x);
|
||||
y = adjustY(gui, y);
|
||||
gui.mc.fontRenderer.drawString(string, x, y, color);
|
||||
}
|
||||
|
||||
public void drawString(GuiBase gui, String string, int x, int y) {
|
||||
drawString(gui, string, x, y, 16777215);
|
||||
}
|
||||
|
||||
public void setTextureSheet(ResourceLocation textureLocation) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation);
|
||||
}
|
||||
|
||||
public void drawCenteredString(GuiBase gui, String string, int y, int colour) {
|
||||
drawString(gui, string, (gui.getXSize() / 2 - gui.mc.fontRenderer.getStringWidth(string) / 2), y, colour);
|
||||
}
|
||||
|
||||
public void drawCenteredString(GuiBase gui, String string, int x, int y, int colour) {
|
||||
drawString(gui, string, (x - gui.mc.fontRenderer.getStringWidth(string) / 2), y, colour);
|
||||
}
|
||||
|
||||
public int getStringWidth(String string) {
|
||||
return Minecraft.getMinecraft().fontRenderer.getStringWidth(string);
|
||||
}
|
||||
|
||||
public void drawSprite(GuiBase gui, ISprite iSprite, int x, int y) {
|
||||
Sprite sprite = iSprite.getSprite(gui.getMachine());
|
||||
if (sprite != null) {
|
||||
if (sprite.hasTextureInfo()) {
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
setTextureSheet(sprite.textureLocation);
|
||||
gui.drawTexturedModalRect(x + gui.guiLeft, y + gui.guiTop, sprite.x, sprite.y, sprite.width, sprite.height);
|
||||
}
|
||||
if (sprite.hasStack()) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(sprite.itemStack, x + gui.guiLeft, y + gui.guiTop);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * scale);
|
||||
}
|
||||
|
||||
public int getPercentage(int MaxValue, int CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
|
||||
public void drawDefaultBackground(GuiScreen gui, int x, int y, int width, int height) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
|
||||
gui.drawTexturedModalRect(x, y, 0, 0, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2);
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.network.packet.PacketFluidConfigSave;
|
||||
import reborncore.common.network.packet.PacketFluidIOSave;
|
||||
import reborncore.common.tile.FluidConfiguration;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.MachineFacing;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class FluidConfigPopupElement extends ElementBase {
|
||||
public boolean filter = false;
|
||||
|
||||
ConfigFluidElement fluidElement;
|
||||
int lastMousex, lastMousey;
|
||||
|
||||
public FluidConfigPopupElement(int x, int y, ConfigFluidElement fluidElement) {
|
||||
super(x, y, Sprite.SLOT_CONFIG_POPUP);
|
||||
this.fluidElement = fluidElement;
|
||||
}
|
||||
|
||||
@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);
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23); //left
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F); //top
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F); //centre
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F); //bottom
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F); //right
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F); //back
|
||||
|
||||
drawSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
|
||||
drawSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui);
|
||||
drawSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), 22, 37, gui);
|
||||
drawSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), 41, 18, gui);
|
||||
drawSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), 41, 37, gui);
|
||||
drawSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), 3, 18, gui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRelease(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
if (isInBox(23, 4, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.UP.getFacing(provider), gui);
|
||||
} else if (isInBox(23, 23, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.FRONT.getFacing(provider), gui);
|
||||
} else if (isInBox(42, 23, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.RIGHT.getFacing(provider), gui);
|
||||
} else if (isInBox(4, 23, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.LEFT.getFacing(provider), gui);
|
||||
} else if (isInBox(23, 42, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.DOWN.getFacing(provider), gui);
|
||||
} else if (isInBox(42, 42, 16, 16, mouseX, mouseY, gui)) {
|
||||
cyleConfig(MachineFacing.BACK.getFacing(provider), gui);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void cyleConfig(EnumFacing side, GuiBase guiBase) {
|
||||
FluidConfiguration.FluidConfig config = guiBase.getMachine().fluidConfiguration.getSideDetail(side);
|
||||
|
||||
FluidConfiguration.ExtractConfig fluidIO = config.getIoConfig().getNext();
|
||||
FluidConfiguration.FluidConfig newConfig = new FluidConfiguration.FluidConfig(side, fluidIO);
|
||||
|
||||
PacketFluidConfigSave packetSave = new PacketFluidConfigSave(guiBase.tile.getPos(), newConfig);
|
||||
NetworkManager.sendToServer(packetSave);
|
||||
}
|
||||
|
||||
public void updateCheckBox(CheckBoxElement checkBoxElement, String type, GuiBase guiBase) {
|
||||
FluidConfiguration configHolder = guiBase.getMachine().fluidConfiguration;
|
||||
boolean input = configHolder.autoInput();
|
||||
boolean output = configHolder.autoOutput();
|
||||
if (type.equalsIgnoreCase("input")) {
|
||||
input = !configHolder.autoInput();
|
||||
}
|
||||
if (type.equalsIgnoreCase("output")) {
|
||||
output = !configHolder.autoOutput();
|
||||
}
|
||||
|
||||
PacketFluidIOSave packetFluidIOSave = new PacketFluidIOSave(guiBase.tile.getPos(), input, output);
|
||||
NetworkManager.sendToServer(packetFluidIOSave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHover(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
lastMousex = mouseX;
|
||||
lastMousey = mouseY;
|
||||
return super.onHover(provider, gui, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void drawSateColor(TileLegacyMachineBase machineBase, EnumFacing side, int inx, int iny, GuiBase gui) {
|
||||
iny += 4;
|
||||
int sx = inx + getX() + gui.guiLeft;
|
||||
int sy = iny + getY() + gui.guiTop;
|
||||
FluidConfiguration fluidConfiguration = machineBase.fluidConfiguration;
|
||||
if (fluidConfiguration == null) {
|
||||
RebornCore.logHelper.debug("Humm, this isnt suppoed to happen");
|
||||
return;
|
||||
}
|
||||
FluidConfiguration.FluidConfig fluidConfig = fluidConfiguration.getSideDetail(side);
|
||||
Color color;
|
||||
switch (fluidConfig.getIoConfig()) {
|
||||
case NONE:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
case INPUT:
|
||||
color = new Color(0, 0, 255, 128);
|
||||
break;
|
||||
case OUTPUT:
|
||||
color = new Color(255, 69, 0, 128);
|
||||
break;
|
||||
case ALL:
|
||||
color = new Color(52, 255, 30, 128);
|
||||
break;
|
||||
default:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
GlStateManager.color(255, 255, 255);
|
||||
GuiUtil.drawGradientRect(sx, sy, 18, 18, color.getRGB(), color.getRGB());
|
||||
GlStateManager.color(255, 255, 255);
|
||||
}
|
||||
|
||||
private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY, GuiBase guiBase) {
|
||||
rectX += getX();
|
||||
rectY += getY();
|
||||
return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY);
|
||||
//return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1;
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui,
|
||||
IBlockAccess blockAccess,
|
||||
IBakedModel model,
|
||||
IBlockState actualState,
|
||||
BlockPos pos,
|
||||
BlockRendererDispatcher dispatcher,
|
||||
int x,
|
||||
int y,
|
||||
float rotAngle,
|
||||
float rotX,
|
||||
float rotY,
|
||||
float rotZ) {
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.translate(8 + gui.guiLeft + this.x + x, 8 + gui.guiTop + this.y + y, 512);
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightness(model, actualState, 1F, false);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
/* GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
// GlStateManager.translate(8 + gui.xFactor + this.x + x, 8 + gui.yFactor + this.y + y, 1000);
|
||||
GlStateManager.translate(gui.xFactor + this.x + x, gui.yFactor + this.y + y, 512);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();*/
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui, IBlockAccess blockAccess, IBakedModel model, IBlockState actualState, BlockPos pos, BlockRendererDispatcher dispatcher, int x, int y) {
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, x, y, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public interface ISprite {
|
||||
Sprite getSprite(TileLegacyMachineBase provider);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Prospector
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public class OffsetSprite {
|
||||
public ISprite sprite;
|
||||
public int offsetX = 0;
|
||||
public int offsetY = 0;
|
||||
|
||||
public OffsetSprite(ISprite sprite, int offsetX, int offsetY) {
|
||||
this.sprite = sprite;
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
}
|
||||
|
||||
public OffsetSprite(ISprite sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public OffsetSprite(Sprite sprite, TileLegacyMachineBase provider) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public ISprite getSprite() {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public int getOffsetX(TileLegacyMachineBase provider) {
|
||||
return offsetX + sprite.getSprite(provider).offsetX;
|
||||
}
|
||||
|
||||
public OffsetSprite setOffsetX(int offsetX) {
|
||||
this.offsetX = offsetX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getOffsetY(TileLegacyMachineBase provider) {
|
||||
return offsetY + sprite.getSprite(provider).offsetY;
|
||||
}
|
||||
|
||||
public OffsetSprite setOffsetY(int offsetY) {
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
All code in this class was taken with permssion from https://github.com/ProfessorProspector/Mechanical-Construct
|
||||
|
||||
A large ammount of modifications have taken place to allow it to work with techreborn.
|
|
@ -1,219 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.network.packet.PacketIOSave;
|
||||
import reborncore.common.network.packet.PacketSlotSave;
|
||||
import reborncore.common.tile.SlotConfiguration;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.MachineFacing;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SlotConfigPopupElement extends ElementBase {
|
||||
int id;
|
||||
public boolean filter = false;
|
||||
|
||||
ConfigSlotElement slotElement;
|
||||
|
||||
|
||||
public SlotConfigPopupElement(int slotId, int x, int y, ConfigSlotElement slotElement) {
|
||||
super(x, y, Sprite.SLOT_CONFIG_POPUP);
|
||||
this.id = slotId;
|
||||
this.slotElement = slotElement;
|
||||
}
|
||||
|
||||
@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);
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23); //left
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F); //top
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F); //centre
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F); //bottom
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F); //right
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F); //back
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRelease(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
if(isInBox(23 , 4, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.UP.getFacing(provider), gui);
|
||||
} else if(isInBox(23 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.FRONT.getFacing(provider), gui);
|
||||
} else if(isInBox(42 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.RIGHT.getFacing(provider), gui);
|
||||
} else if(isInBox(4 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.LEFT.getFacing(provider), gui);
|
||||
} else if(isInBox(23 , 42, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.DOWN.getFacing(provider), gui);
|
||||
} else if(isInBox(42 , 42, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.BACK.getFacing(provider), gui);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void cyleSlotConfig(EnumFacing side, GuiBase guiBase){
|
||||
SlotConfiguration.SlotConfig currentSlot = guiBase.getMachine().slotConfiguration.getSlotDetails(id).getSideDetail(side);
|
||||
|
||||
SlotConfiguration.SlotIO slotIO = new SlotConfiguration.SlotIO(currentSlot.getSlotIO().getIoConfig().getNext());
|
||||
SlotConfiguration.SlotConfig newConfig = new SlotConfiguration.SlotConfig(side, slotIO, id);
|
||||
PacketSlotSave packetSlotSave = new PacketSlotSave(guiBase.tile.getPos(), newConfig);
|
||||
NetworkManager.sendToServer(packetSlotSave);
|
||||
}
|
||||
|
||||
public void updateCheckBox(CheckBoxElement checkBoxElement, String type, GuiBase guiBase){
|
||||
SlotConfiguration.SlotConfigHolder configHolder = guiBase.getMachine().slotConfiguration.getSlotDetails(id);
|
||||
boolean input = configHolder.autoInput();
|
||||
boolean output = configHolder.autoOutput();
|
||||
boolean filter = configHolder.filter();
|
||||
if(type.equalsIgnoreCase("input")){
|
||||
input = !configHolder.autoInput();
|
||||
}
|
||||
if(type.equalsIgnoreCase("output")){
|
||||
output = !configHolder.autoOutput();
|
||||
}
|
||||
if(type.equalsIgnoreCase("filter")){
|
||||
filter = !configHolder.filter();
|
||||
}
|
||||
|
||||
PacketIOSave packetSlotSave = new PacketIOSave(guiBase.tile.getPos(), id, input, output, filter);
|
||||
NetworkManager.sendToServer(packetSlotSave);
|
||||
}
|
||||
|
||||
private void drawSlotSateColor(TileLegacyMachineBase machineBase, EnumFacing side, int slotID, int inx, int iny, GuiBase gui){
|
||||
iny += 4;
|
||||
int sx = inx + getX() + gui.guiLeft;
|
||||
int sy = iny + getY() + gui.guiTop;
|
||||
SlotConfiguration.SlotConfigHolder slotConfigHolder = machineBase.slotConfiguration.getSlotDetails(slotID);
|
||||
if(slotConfigHolder == null){
|
||||
RebornCore.logHelper.debug("Humm, this isnt suppoed to happen");
|
||||
return;
|
||||
}
|
||||
SlotConfiguration.SlotConfig slotConfig = slotConfigHolder.getSideDetail(side);
|
||||
Color color;
|
||||
switch (slotConfig.getSlotIO().getIoConfig()){
|
||||
case NONE:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
case INPUT:
|
||||
color = new Color(0, 0, 255, 128);
|
||||
break;
|
||||
case OUTPUT:
|
||||
color = new Color(255, 69, 0, 128);
|
||||
break;
|
||||
default:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
GlStateManager.color(255, 255, 255);
|
||||
GuiUtil.drawGradientRect(sx, sy, 18, 18, color.getRGB(), color.getRGB());
|
||||
GlStateManager.color(255, 255, 255);
|
||||
|
||||
}
|
||||
|
||||
private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY, GuiBase guiBase){
|
||||
rectX += getX();
|
||||
rectY += getY();
|
||||
return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY);
|
||||
//return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1;
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui,
|
||||
IBlockAccess blockAccess,
|
||||
IBakedModel model,
|
||||
IBlockState actualState,
|
||||
BlockPos pos,
|
||||
BlockRendererDispatcher dispatcher,
|
||||
int x,
|
||||
int y,
|
||||
float rotAngle,
|
||||
float rotX,
|
||||
float rotY,
|
||||
float rotZ) {
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.translate(8 + gui.guiLeft + this.x + x, 8 + gui.guiTop + this.y + y, 512);
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightness(model, actualState, 1F, false);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
/* GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
// GlStateManager.translate(8 + gui.xFactor + this.x + x, 8 + gui.yFactor + this.y + y, 1000);
|
||||
GlStateManager.translate(gui.xFactor + this.x + x, gui.yFactor + this.y + y, 512);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();*/
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui, IBlockAccess blockAccess, IBakedModel model, IBlockState actualState, BlockPos pos, BlockRendererDispatcher dispatcher, int x, int y) {
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, x, y, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class SlotElement extends ElementBase {
|
||||
protected ItemStackHandler slotInventory;
|
||||
protected SlotType type;
|
||||
int slotId, slotX, slotY;
|
||||
|
||||
public SlotElement(ItemStackHandler slotInventory, int slotId, int slotX, int slotY, SlotType type, int x, int y) {
|
||||
super(x, y, type.getSprite());
|
||||
this.type = type;
|
||||
this.slotInventory = slotInventory;
|
||||
this.slotId = slotId;
|
||||
this.slotX = slotX;
|
||||
this.slotY = slotY;
|
||||
}
|
||||
|
||||
public SlotType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ItemStackHandler getSlotInventory() {
|
||||
return slotInventory;
|
||||
}
|
||||
|
||||
public int getSlotId() {
|
||||
return slotId;
|
||||
}
|
||||
|
||||
public int getSlotX() {
|
||||
return slotX;
|
||||
}
|
||||
|
||||
public int getSlotY() {
|
||||
return slotY;
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
public enum SlotType {
|
||||
NORMAL(1, 1, Sprite.SLOT_NORMAL, Sprite.BUTTON_SLOT_NORMAL, Sprite.BUTTON_HOVER_OVERLAY_SLOT_NORMAL);
|
||||
|
||||
int slotOffsetX;
|
||||
int slotOffsetY;
|
||||
Sprite sprite;
|
||||
Sprite buttonSprite;
|
||||
Sprite buttonHoverOverlay;
|
||||
|
||||
SlotType(int slotOffsetX, int slotOffsetY, Sprite sprite, Sprite buttonSprite, Sprite buttonHoverOverlay) {
|
||||
this.slotOffsetX = slotOffsetX;
|
||||
this.slotOffsetY = slotOffsetY;
|
||||
this.sprite = sprite;
|
||||
this.buttonSprite = buttonSprite;
|
||||
this.buttonHoverOverlay = buttonHoverOverlay;
|
||||
}
|
||||
|
||||
SlotType(int slotOffset, Sprite sprite) {
|
||||
this.slotOffsetX = slotOffset;
|
||||
this.slotOffsetY = slotOffset;
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public int getSlotOffsetX() {
|
||||
return slotOffsetX;
|
||||
}
|
||||
|
||||
public int getSlotOffsetY() {
|
||||
return slotOffsetY;
|
||||
}
|
||||
|
||||
public Sprite getSprite() {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public Sprite getButtonSprite() {
|
||||
return buttonSprite;
|
||||
}
|
||||
|
||||
public Sprite getButtonHoverOverlay() {
|
||||
return buttonHoverOverlay;
|
||||
}
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public class Sprite implements ISprite {
|
||||
public static final Sprite EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 0, 0);
|
||||
public static final Sprite SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 18, 18);
|
||||
public static final Sprite CHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 18, 0, 18, 18);
|
||||
public static final Sprite DISCHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 36, 0, 18, 18);
|
||||
public static final Sprite ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 18, 12, 40);
|
||||
public static final Sprite ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 12, 18, 14, 42);
|
||||
public static final Sprite TOP_ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 215, 167, 2);
|
||||
public static final Sprite TOP_ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 0, 217, 169, 3);
|
||||
public static final Sprite LEFT_TAB = new Sprite(ElementBase.MECH_ELEMENTS, 0, 86, 23, 26);
|
||||
public static final Sprite LEFT_TAB_SELECTED = new Sprite(ElementBase.MECH_ELEMENTS, 0, 60, 29, 26);
|
||||
public static final Sprite CONFIGURE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 18, 16, 16);
|
||||
public static final Sprite REDSTONE_DISABLED_ICON = new Sprite(new ItemStack(Items.GUNPOWDER));
|
||||
public static final Sprite REDSTONE_LOW_ICON = new Sprite(new ItemStack(Items.REDSTONE));
|
||||
public static final Sprite REDSTONE_HIGH_ICON = new Sprite(new ItemStack(Blocks.REDSTONE_TORCH));
|
||||
public static final Sprite UPGRADE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 34, 16, 16);
|
||||
public static final Sprite ENERGY_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 46, 19, 9, 13);
|
||||
public static final Sprite ENERGY_ICON_EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 62, 19, 9, 13);
|
||||
public static final Sprite JEI_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 42, 34, 16, 16);
|
||||
public static final Sprite BUTTON_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 54, 0, 18, 18);
|
||||
public static final Sprite FAKE_SLOT = new Sprite(ElementBase.MECH_ELEMENTS, 72, 0, 18, 18);
|
||||
public static final Sprite BUTTON_HOVER_OVERLAY_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 90, 0, 18, 18);
|
||||
public static final Sprite SLOT_CONFIG_POPUP = new Sprite(ElementBase.MECH_ELEMENTS, 29, 60, 62, 62);
|
||||
public static final Sprite.Button EXIT_BUTTON = new Sprite.Button(new Sprite(ElementBase.MECH_ELEMENTS, 26, 122, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 39, 122, 13, 13));
|
||||
public static final Sprite.CheckBox DARK_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 18, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 18, 16, 13));
|
||||
public static final Sprite.CheckBox LIGHT_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 31, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 31, 16, 13));
|
||||
|
||||
public final ResourceLocation textureLocation;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int width;
|
||||
public final int height;
|
||||
public int offsetX = 0;
|
||||
public int offsetY = 0;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public Sprite(ResourceLocation textureLocation, int x, int y, int width, int height) {
|
||||
this.textureLocation = textureLocation;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.itemStack = null;
|
||||
}
|
||||
|
||||
public Sprite(ItemStack stack) {
|
||||
this.textureLocation = null;
|
||||
this.x = -1;
|
||||
this.y = -1;
|
||||
this.width = -1;
|
||||
this.height = -1;
|
||||
this.itemStack = stack;
|
||||
}
|
||||
|
||||
public boolean hasStack() {
|
||||
return itemStack != null;
|
||||
}
|
||||
|
||||
public boolean hasTextureInfo() {
|
||||
return x >= 0 && y >= 0 && width >= 0 && height >= 0;
|
||||
}
|
||||
|
||||
public Sprite setOffsetX(int offsetX) {
|
||||
this.offsetX = offsetX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sprite setOffsetY(int offsetY) {
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprite getSprite(TileLegacyMachineBase provider) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Button {
|
||||
private Sprite normal;
|
||||
private Sprite hovered;
|
||||
|
||||
public Button(Sprite normal, Sprite hovered) {
|
||||
this.normal = normal;
|
||||
this.hovered = hovered;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getHovered() {
|
||||
return hovered;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ToggleButton {
|
||||
private Sprite normal;
|
||||
private Sprite hovered;
|
||||
private Sprite pressed;
|
||||
|
||||
public ToggleButton(Sprite normal, Sprite hovered, Sprite pressed) {
|
||||
this.normal = normal;
|
||||
this.hovered = hovered;
|
||||
this.pressed = pressed;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getHovered() {
|
||||
return hovered;
|
||||
}
|
||||
|
||||
public Sprite getPressed() {
|
||||
return pressed;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckBox {
|
||||
private Sprite normal;
|
||||
private Sprite ticked;
|
||||
|
||||
public CheckBox(Sprite normal, Sprite ticked) {
|
||||
this.normal = normal;
|
||||
this.ticked = ticked;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getTicked() {
|
||||
return ticked;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpriteContainer {
|
||||
public List<OffsetSprite> offsetSprites = new ArrayList<>();
|
||||
|
||||
public SpriteContainer setSprite(int index, OffsetSprite sprite) {
|
||||
offsetSprites.set(index, sprite);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer setSprite(int index, ISprite sprite, int offsetX, int offsetY) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX + offsetX).setOffsetY(((Sprite) sprite).offsetY + offsetY));
|
||||
} else {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite, offsetX, offsetY));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer setSprite(int index, ISprite sprite) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX).setOffsetY(((Sprite) sprite).offsetY));
|
||||
} else {
|
||||
offsetSprites.add(index, new OffsetSprite(sprite));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(OffsetSprite sprite) {
|
||||
offsetSprites.add(sprite);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(ISprite sprite, int offsetX, int offsetY) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.add(new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX + offsetX).setOffsetY(((Sprite) sprite).offsetY + offsetY));
|
||||
} else {
|
||||
offsetSprites.add(new OffsetSprite(sprite, offsetX, offsetY));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(ISprite sprite) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.add(new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX).setOffsetY(((Sprite) sprite).offsetY));
|
||||
} else {
|
||||
offsetSprites.add(new OffsetSprite(sprite));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
public class GuiButtonHologram extends GuiButton {
|
||||
|
||||
GuiBase.Layer layer;
|
||||
GuiBase gui;
|
||||
|
||||
public GuiButtonHologram(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) {
|
||||
super(buttonId, x, y, 20, 12, "");
|
||||
this.layer = layer;
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
|
||||
if (this.enabled && this.visible && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButtonForegroundLayer(int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft p_191745_1_, int p_191745_2_, int p_191745_3_, float p_191745_4_) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
public class GuiButtonPowerBar extends GuiButton {
|
||||
|
||||
GuiBase.Layer layer;
|
||||
GuiBase gui;
|
||||
|
||||
public GuiButtonPowerBar(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) {
|
||||
super(buttonId, x, y, 12, 48, "");
|
||||
this.layer = layer;
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
|
||||
if (this.enabled && this.visible && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) {
|
||||
PowerSystem.bumpPowerConfig();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButtonForegroundLayer(int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft p_191745_1_, int p_191745_2_, int p_191745_3_, float p_191745_4_) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public class GuiButtonUpDown extends GuiButton {
|
||||
|
||||
GuiBase.Layer layer;
|
||||
GuiBase gui;
|
||||
|
||||
public GuiButtonUpDown(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) {
|
||||
super(buttonId, x, y, 12, 12, "");
|
||||
this.layer = layer;
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
if (this.enabled && this.visible && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
||||
// We already have texture drawn
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.LanguageMap;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class GuiWidget<T extends Container> extends GuiContainer {
|
||||
|
||||
public static final LanguageMap translate = ObfuscationReflectionHelper.getPrivateValue(LanguageMap.class, null, 2);
|
||||
|
||||
private final ArrayList<Widget> widgets = new ArrayList<>();
|
||||
private final ResourceLocation background;
|
||||
|
||||
public GuiWidget(T inventorySlotsIn, ResourceLocation background, int xSize, int ySize) {
|
||||
super(inventorySlotsIn);
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getContainer() {
|
||||
return (T) inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
widgets.clear();
|
||||
initWidgets();
|
||||
}
|
||||
|
||||
public void addWidget(Widget widget) {
|
||||
widgets.add(widget);
|
||||
}
|
||||
|
||||
public void removeWidget(Widget widget) {
|
||||
widgets.remove(widget);
|
||||
}
|
||||
|
||||
public abstract void initWidgets();
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(background);
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
String name = translate.translateKey("tile.techreborn.industrialgrinder.name");
|
||||
|
||||
fontRenderer.drawString(name, xSize / 2 - fontRenderer.getStringWidth(name) / 2, 6, 4210752);
|
||||
fontRenderer.drawString(translate.translateKey("container.inventory"), 8, ySize - 94, 4210752);
|
||||
|
||||
for (Widget widget : widgets)
|
||||
widget.drawWidget(this, x, y, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer() {
|
||||
return fontRenderer;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import techreborn.client.gui.widget.tooltip.ToolTip;
|
||||
|
||||
public abstract class Widget {
|
||||
|
||||
private final int x, y;
|
||||
protected final int width, height;
|
||||
|
||||
private ToolTip toolTip;
|
||||
|
||||
public Widget(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public ToolTip getToolTip() {
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
public void setToolTip(ToolTip toolTip) {
|
||||
this.toolTip = toolTip;
|
||||
}
|
||||
|
||||
public final void drawWidget(GuiWidget<?> gui, int cornerX, int cornerY, int mouseX, int mouseY) {
|
||||
int drawX = cornerX + x;
|
||||
int drawY = cornerY + y;
|
||||
if (toolTip != null && drawX > mouseX && drawY > mouseY &&
|
||||
drawX + width < mouseX && drawY + height < mouseY) {
|
||||
toolTip.draw(gui.getFontRenderer(), mouseX, mouseY);
|
||||
}
|
||||
draw(gui, drawX, drawY);
|
||||
}
|
||||
|
||||
protected abstract void draw(GuiScreen guiScreen, int x, int y);
|
||||
|
||||
protected abstract void mouseClick(GuiWidget<?> guiWidget, int mouseX, int mouseY);
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget.tooltip;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ToolTip {
|
||||
|
||||
protected ArrayList<ToolTipLine> lines = new ArrayList<>();
|
||||
|
||||
public ToolTip(String... textLines) {
|
||||
for (String text : textLines)
|
||||
lines.add(new ToolTipLine(text));
|
||||
}
|
||||
|
||||
public ToolTip(ToolTipLine... toolTipLines) {
|
||||
Collections.addAll(lines, toolTipLines);
|
||||
}
|
||||
|
||||
public ToolTip(int linesSize) {
|
||||
for (int i = 0; i < linesSize; i++)
|
||||
lines.add(new ToolTipLine());
|
||||
}
|
||||
|
||||
public void addLine(ToolTipLine toolTipLine) {
|
||||
lines.add(toolTipLine);
|
||||
}
|
||||
|
||||
public void removeLine(int index) {
|
||||
lines.remove(index);
|
||||
}
|
||||
|
||||
public ToolTipLine getLine(int index) {
|
||||
return lines.get(index);
|
||||
}
|
||||
|
||||
public ArrayList<ToolTipLine> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
protected void refresh() {}
|
||||
|
||||
public void draw(FontRenderer font, int mouseX, int mouseY) {
|
||||
refresh();
|
||||
int maxLineLength = 0;
|
||||
int textX = mouseX + 3;
|
||||
int textY = mouseY + 3;
|
||||
for (ToolTipLine toolTipLine : lines) {
|
||||
toolTipLine.draw(font, textX, textY);
|
||||
textY += (font.FONT_HEIGHT + 3);
|
||||
int lineWidth = toolTipLine.getWidth(font);
|
||||
if (lineWidth > maxLineLength)
|
||||
maxLineLength = lineWidth;
|
||||
}
|
||||
GuiUtil.drawTooltipBox(mouseX, mouseY, maxLineLength, textY + 3);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.widget.tooltip;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class ToolTipLine {
|
||||
|
||||
private String line;
|
||||
private int color;
|
||||
private boolean shadowed;
|
||||
|
||||
public ToolTipLine(String line, int color, boolean shadowed) {
|
||||
this.line = line;
|
||||
this.color = color;
|
||||
this.shadowed = shadowed;
|
||||
}
|
||||
|
||||
public ToolTipLine(String line, int color) {
|
||||
this(line, color, false);
|
||||
}
|
||||
|
||||
public ToolTipLine(String line, boolean shadowed) {
|
||||
this(line, 0xFFFFFF, shadowed);
|
||||
}
|
||||
|
||||
public ToolTipLine(String line) {
|
||||
this(line, 0xFFFFFF, false);
|
||||
}
|
||||
|
||||
public ToolTipLine() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public String getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public void setLine(String line) {
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public boolean isShadowed() {
|
||||
return shadowed;
|
||||
}
|
||||
|
||||
public void setShadowed(boolean shadowed) {
|
||||
this.shadowed = shadowed;
|
||||
}
|
||||
|
||||
public int getWidth(FontRenderer fontRenderer) {
|
||||
return fontRenderer.getStringWidth(getLine());
|
||||
}
|
||||
|
||||
public void draw(FontRenderer fontRenderer, int x, int y) {
|
||||
fontRenderer.drawString(getLine(), x, y, color, isShadowed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ToolTipLine that = (ToolTipLine) o;
|
||||
return color == that.color &&
|
||||
shadowed == that.shadowed &&
|
||||
line.equals(that.line);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = line.hashCode();
|
||||
result = 31 * result + color;
|
||||
result = 31 * result + (shadowed ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -51,6 +51,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
|||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.Core;
|
||||
import techreborn.api.fluidreplicator.FluidReplicatorRecipe;
|
||||
|
@ -63,7 +64,7 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
|
|||
import techreborn.api.recipe.machines.*;
|
||||
import techreborn.blocks.cable.EnumCableType;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import reborncore.client.gui.builder.slot.GuiSlotConfiguration;
|
||||
import techreborn.compat.CompatConfigs;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
|
||||
|
|
|
@ -31,7 +31,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.AlloySmelterRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -32,7 +32,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -31,7 +31,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.CentrifugeRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -31,7 +31,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.ChemicalReactorRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.CompressorRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -31,7 +31,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.DistillationTowerRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.ExtractorRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -36,7 +36,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.api.fluidreplicator.FluidReplicatorRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.init.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.GrinderRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
|||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import reborncore.client.gui.builder.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.client.renderer.block.statemap.StateMap;
|
|||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.util.RecipeBookClient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -40,14 +41,12 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|||
import prospector.shootingstar.ShootingStar;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.client.hud.StackInfoHUD;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import techreborn.blocks.BlockRubberLeaves;
|
||||
import techreborn.client.ClientEventHandler;
|
||||
import reborncore.client.IconSupplier;
|
||||
import techreborn.client.RegisterItemJsons;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.GuiFluidConfiguration;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.slot.GuiFluidConfiguration;
|
||||
import reborncore.client.gui.builder.slot.GuiSlotConfiguration;
|
||||
import techreborn.client.keybindings.KeyBindings;
|
||||
import techreborn.client.render.ModelDynamicCell;
|
||||
import techreborn.client.render.entitys.RenderNukePrimed;
|
||||
|
@ -55,13 +54,13 @@ import techreborn.entities.EntityNukePrimed;
|
|||
import techreborn.events.FluidBlockModelHandler;
|
||||
import techreborn.events.StackToolTipEvent;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.items.DynamicCell;
|
||||
import techreborn.items.ItemFrequencyTransmitter;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
public static MultiblockRenderEvent multiblockRenderEvent;
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
super.preInit(event);
|
||||
|
@ -78,14 +77,14 @@ public class ClientProxy extends CommonProxy {
|
|||
public void init(FMLInitializationEvent event) {
|
||||
super.init(event);
|
||||
MinecraftForge.EVENT_BUS.register(new StackToolTipEvent());
|
||||
multiblockRenderEvent = new MultiblockRenderEvent();
|
||||
MinecraftForge.EVENT_BUS.register(GuiSlotConfiguration.class);
|
||||
MinecraftForge.EVENT_BUS.register(GuiFluidConfiguration.class);
|
||||
MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
|
||||
// TODO FIX ME
|
||||
ClientRegistry.registerKeyBinding(KeyBindings.config);
|
||||
StateMap rubberLeavesStateMap = new StateMap.Builder().ignore(BlockRubberLeaves.CHECK_DECAY, BlockRubberLeaves.DECAYABLE).build();
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.RUBBER_LEAVES, rubberLeavesStateMap);
|
||||
GuiBase.wrenchStack = new ItemStack(ModItems.WRENCH);
|
||||
GuiBase.fluidCellProvider = DynamicCell::getCellWithFluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
Loading…
Add table
Reference in a new issue