Merge remote-tracking branch 'remotes/origin/1.12' into 1.13-prep
# Conflicts: # src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java # src/main/java/techreborn/client/container/ContainerPda.java # src/main/java/techreborn/client/gui/TRBuilder.java # src/main/java/techreborn/compat/crafttweaker/CTFusionReactor.java # src/main/java/techreborn/compat/crafttweaker/CTGeneric.java # src/main/java/techreborn/compat/jei/RecipeUtil.java # src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java # src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java # src/main/java/techreborn/compat/jei/assemblingMachine/AssemblingMachineRecipeCategory.java # src/main/java/techreborn/compat/jei/blastFurnace/BlastFurnaceRecipeCategory.java # src/main/java/techreborn/compat/jei/centrifuge/CentrifugeRecipeCategory.java # src/main/java/techreborn/compat/jei/chemicalReactor/ChemicalReactorRecipeCategory.java # src/main/java/techreborn/compat/jei/compressor/CompressorRecipeCategory.java # src/main/java/techreborn/compat/jei/distillationTower/DistillationTowerRecipeCategory.java # src/main/java/techreborn/compat/jei/extractor/ExtractorRecipeCategory.java # src/main/java/techreborn/compat/jei/fluidReplicator/FluidReplicatorRecipeCategory.java # src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeCategory.java # src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeWrapper.java # src/main/java/techreborn/compat/jei/grinder/GrinderRecipeCategory.java # src/main/java/techreborn/compat/jei/implosionCompressor/ImplosionCompressorRecipeCategory.java # src/main/java/techreborn/compat/jei/industrialElectrolyzer/IndustrialElectrolyzerRecipeCategory.java # src/main/java/techreborn/compat/jei/industrialGrinder/IndustrialGrinderRecipeCategory.java # src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java # src/main/java/techreborn/compat/jei/rollingMachine/RollingMachineRecipeCategory.java # src/main/java/techreborn/compat/jei/vacuumFreezer/VacuumFreezerRecipeCategory.java # src/main/java/techreborn/init/ModBlocks.java # src/main/java/techreborn/init/ModTileEntities.java # src/main/java/techreborn/init/recipes/CraftingTableRecipes.java # src/main/java/techreborn/init/recipes/IndustrialGrinderRecipes.java # src/main/java/techreborn/items/tools/ItemAdvancedDrill.java # src/main/java/techreborn/packets/PacketAutoCraftingTableLock.java # src/main/resources/assets/techreborn/lang/en_us.lang # src/main/resources/assets/techreborn/loot_tables/chests/abandoned_mineshaft.json # src/main/resources/assets/techreborn/loot_tables/chests/desert_pyramid.json # src/main/resources/assets/techreborn/loot_tables/chests/igloo_chest.json # src/main/resources/assets/techreborn/loot_tables/chests/jungle_temple.json # src/main/resources/assets/techreborn/loot_tables/chests/simple_dungeon.json # src/main/resources/assets/techreborn/loot_tables/chests/village_blacksmith.json
This commit is contained in:
commit
6060a97855
77 changed files with 1863 additions and 4017 deletions
|
@ -61,7 +61,7 @@ public class GuiAESU extends GuiBase {
|
|||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
if(!GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType == SlotConfigType.NONE){
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(0.6, 0.6, 1);
|
||||
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/"
|
||||
|
|
|
@ -28,7 +28,9 @@ 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;
|
||||
|
@ -36,8 +38,11 @@ import org.lwjgl.input.Keyboard;
|
|||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.container.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;
|
||||
|
@ -53,7 +58,7 @@ public class GuiBase extends GuiContainer {
|
|||
public TRBuilder builder = new TRBuilder();
|
||||
public TileEntity tile;
|
||||
public BuiltContainer container;
|
||||
public static boolean showSlotConfig = false;
|
||||
public static SlotConfigType slotConfigType = SlotConfigType.NONE;
|
||||
|
||||
public boolean upgrades;
|
||||
|
||||
|
@ -61,7 +66,7 @@ public class GuiBase extends GuiContainer {
|
|||
super(container);
|
||||
this.tile = tile;
|
||||
this.container = container;
|
||||
showSlotConfig = false;
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
}
|
||||
|
||||
protected void drawSlot(int x, int y, Layer layer) {
|
||||
|
@ -119,6 +124,9 @@ public class GuiBase extends GuiContainer {
|
|||
public void initGui() {
|
||||
super.initGui();
|
||||
GuiSlotConfiguration.init(this);
|
||||
if(getMachine().getTank() != null && getMachine().showTankConfig()){
|
||||
GuiFluidConfiguration.init(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,7 +144,10 @@ public class GuiBase extends GuiContainer {
|
|||
}
|
||||
}
|
||||
if(getMachine().hasSlotConfig()){
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,10 +164,14 @@ public class GuiBase extends GuiContainer {
|
|||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.buttonList.clear();
|
||||
drawTitle();
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
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;
|
||||
|
@ -168,6 +183,13 @@ public class GuiBase extends GuiContainer {
|
|||
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
|
||||
|
@ -212,19 +234,27 @@ public class GuiBase extends GuiContainer {
|
|||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
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(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -235,22 +265,38 @@ public class GuiBase extends GuiContainer {
|
|||
offset = 80;
|
||||
}
|
||||
if(isPointInRegion(-26, 84 - offset, 30, 30, mouseX, mouseY) && getMachine().hasSlotConfig()){
|
||||
showSlotConfig = !showSlotConfig;
|
||||
if(!showSlotConfig){
|
||||
if(slotConfigType != SlotConfigType.ITEMS){
|
||||
slotConfigType = SlotConfigType.ITEMS;
|
||||
} else {
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
}
|
||||
if(slotConfigType == SlotConfigType.ITEMS){
|
||||
GuiSlotConfiguration.reset();
|
||||
}
|
||||
}
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
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(showSlotConfig){
|
||||
if(slotConfigType == SlotConfigType.ITEMS){
|
||||
if(isCtrlKeyDown() && keyCode == Keyboard.KEY_C){
|
||||
GuiSlotConfiguration.copyToClipboard();
|
||||
return;
|
||||
|
@ -264,7 +310,7 @@ public class GuiBase extends GuiContainer {
|
|||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
showSlotConfig = false;
|
||||
slotConfigType = SlotConfigType.NONE;
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
|
@ -276,13 +322,14 @@ public class GuiBase extends GuiContainer {
|
|||
return (TileLegacyMachineBase) tile;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public enum SlotRender {
|
||||
STANDARD, OUTPUT, NONE, SPRITE;
|
||||
|
||||
}
|
||||
|
||||
public enum Layer {
|
||||
BACKGROUND, FOREGROUND
|
||||
}
|
||||
|
||||
public enum SlotConfigType{
|
||||
NONE,
|
||||
ITEMS,
|
||||
FLUIDS
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class GuiBatbox extends GuiBase {
|
|||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
if(!GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType == SlotConfigType.NONE){
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(0.6, 0.6, 5);
|
||||
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||
|
|
|
@ -107,7 +107,7 @@ public class GuiBlastFurnace extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -103,7 +103,7 @@ public class GuiDistillationTower extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -112,7 +112,7 @@ public class GuiFluidReplicator extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -122,7 +122,7 @@ public class GuiFusionReactor extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
updateMultiBlockRender();
|
||||
} else {
|
||||
|
|
|
@ -105,7 +105,7 @@ public class GuiImplosionCompressor extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -109,7 +109,7 @@ public class GuiIndustrialGrinder extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -108,7 +108,7 @@ public class GuiIndustrialSawmill extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -27,7 +27,9 @@ package techreborn.client.gui;
|
|||
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.util.ResourceLocation;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.tiles.tier0.TileIronFurnace;
|
||||
|
||||
public class GuiIronFurnace extends GuiBase {
|
||||
|
@ -48,7 +50,7 @@ public class GuiIronFurnace extends GuiBase {
|
|||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
this.drawDefaultBackground();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, p_146976_2_, p_146976_3_, upgrades);
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, p_146976_2_, p_146976_3_, upgrades, new ItemStack(ModItems.WRENCH));
|
||||
this.mc.getTextureManager().bindTexture(GuiIronFurnace.texture);
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class GuiMFE extends GuiBase {
|
|||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
if(!GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType == SlotConfigType.NONE){
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(0.6, 0.6, 1);
|
||||
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.tiles.TileQuantumTank;
|
||||
|
@ -52,12 +51,6 @@ public class GuiQuantumTank extends GuiBase {
|
|||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
||||
final String name = I18n.format("tile.techreborn:quantum_tank.name");
|
||||
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
|
||||
FluidStack fluid = this.quantumTank.tank.getFluid();
|
||||
if(fluid != null){
|
||||
this.fontRenderer.drawString( "Fluid Type:", 10, 20, 4210752);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GuiVacuumFreezer extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY, int buttonID, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -104,7 +104,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawProgressBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -152,7 +152,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawTank(GuiBase gui, int x, int y, int mouseX, int mouseY, FluidStack fluid, int maxCapacity, boolean isTankEmpty, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -213,7 +213,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawJEIButton(GuiBase gui, int x, int y, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (Loader.isModLoaded("jei")) {
|
||||
|
@ -227,7 +227,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawLockButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer, boolean locked) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -251,7 +251,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawHologramButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -278,7 +278,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawUpDownButtons(GuiBase gui, int x, int y, GuiBase.Layer layer){
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -293,7 +293,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawUpDownButtonsSmall(GuiBase gui, int x, int y, GuiBase.Layer layer){
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -308,7 +308,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawEnergyOutput(GuiBase gui, int right, int top, int maxOutput, GuiBase.Layer layer){
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
String text = PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxOutput) + " "
|
||||
|
@ -325,7 +325,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -360,7 +360,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawBigHeatBar(GuiBase gui, int x, int y, int value, int max, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -380,7 +380,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawMultiblockMissingBar(GuiBase gui, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE){
|
||||
return;
|
||||
}
|
||||
int x = 0;
|
||||
|
@ -448,8 +448,8 @@ public class TRBuilder extends GuiBuilder {
|
|||
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){
|
||||
int offset = 0;
|
||||
public void drawSlotTab(GuiScreen gui, int posX, int posY, int mouseX, int mouseY, boolean upgrades, ItemStack stack){
|
||||
int offset = -1;
|
||||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuiSlotConfiguration {
|
||||
public class GuiSlotConfiguration {
|
||||
|
||||
static HashMap<Integer, ConfigSlotElement> slotElementMap = new HashMap<>();
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class GuiSlotConfiguration {
|
|||
}
|
||||
|
||||
public static List<Rectangle> getExtraSpace(GuiBase guiBase){
|
||||
if(!GuiBase.showSlotConfig || slectedSlot == -1){
|
||||
if(GuiBase.slotConfigType != GuiBase.SlotConfigType.ITEMS || slectedSlot == -1){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Rectangle> list = new ArrayList<>();
|
||||
|
|
|
@ -27,14 +27,17 @@ 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;
|
||||
TileLegacyMachineBase machineBase;
|
||||
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) {
|
||||
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;
|
||||
|
@ -42,13 +45,14 @@ public class CheckBoxElement extends ElementBase {
|
|||
this.machineBase = machineBase;
|
||||
this.label = label;
|
||||
this.labelColor = labelColor;
|
||||
if (isTicked()) {
|
||||
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 (isTicked()) {
|
||||
if (ticked.test(this)) {
|
||||
element.container.setSprite(0, checkBoxSprite.getTicked());
|
||||
} else {
|
||||
element.container.setSprite(0, checkBoxSprite.getNormal());
|
||||
|
@ -61,21 +65,11 @@ public class CheckBoxElement extends ElementBase {
|
|||
public void draw(GuiBase gui) {
|
||||
// super.draw(gui);
|
||||
ISprite sprite = checkBoxSprite.getNormal();
|
||||
if(isTicked()){
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isTicked() {
|
||||
if(type.equalsIgnoreCase("output")){
|
||||
return machineBase.slotConfiguration.getSlotDetails(slotID).autoOutput();
|
||||
}
|
||||
if(type.equalsIgnoreCase("filter")){
|
||||
return machineBase.slotConfiguration.getSlotDetails(slotID).filter();
|
||||
}
|
||||
return machineBase.slotConfiguration.getSlotDetails(slotID).autoInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -58,14 +58,17 @@ public class ConfigSlotElement extends ElementBase {
|
|||
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()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
|
||||
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()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
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;
|
||||
}));
|
||||
|
@ -73,7 +76,8 @@ public class ConfigSlotElement extends ElementBase {
|
|||
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()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
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;
|
||||
}));
|
||||
|
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue