Initial fluid config work

This commit is contained in:
Modmuss50 2018-08-10 17:45:16 +01:00
parent 062114f3a9
commit 39475f86dc
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
29 changed files with 579 additions and 185 deletions

View file

@ -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()) + "/"

View file

@ -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,7 @@ public class GuiBase extends GuiContainer {
public void initGui() {
super.initGui();
GuiSlotConfiguration.init(this);
GuiFluidConfiguration.init(this);
}
@Override
@ -136,7 +142,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 +162,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 +181,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 +232,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 +263,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 +308,7 @@ public class GuiBase extends GuiContainer {
@Override
public void onGuiClosed() {
showSlotConfig = false;
slotConfigType = SlotConfigType.NONE;
super.onGuiClosed();
}
@ -276,13 +320,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
}
}

View file

@ -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);

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -128,7 +128,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 {

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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.

View file

@ -42,7 +42,6 @@ import reborncore.api.tile.IUpgradeable;
import reborncore.client.guibuilder.GuiBuilder;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.init.ModItems;
import techreborn.lib.ModInfo;
import techreborn.proxies.ClientProxy;
@ -62,7 +61,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 +103,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 +151,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 +212,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 +226,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 +250,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 +277,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 +292,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 +307,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 +324,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 +359,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 +379,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,14 +447,14 @@ 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;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
gui.drawTexturedModalRect(posX - 26, posY + 84 - offset, 157, 148, 30, 30);
renderItemStack(new ItemStack(ModItems.WRENCH), posX - 19, posY + 92 - offset);
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) {

View file

@ -0,0 +1,129 @@
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;
}
}

View file

@ -52,7 +52,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<>();
@ -237,7 +237,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<>();

View file

@ -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();
}
}

View file

@ -0,0 +1,80 @@
/*
* 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 techreborn.client.gui.slot.GuiSlotConfiguration;
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) -> {
GuiSlotConfiguration.slectedSlot = -1;
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;
}
}

View file

@ -61,11 +61,13 @@ public class ConfigSlotElement extends ElementBase {
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 +75,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;
}));

View file

@ -0,0 +1,212 @@
/*
* 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;
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.FluidIO fluidIO = new FluidConfiguration.FluidIO(config.getFluidIO().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);
}
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 slotConfig = fluidConfiguration.getSideDetail(side);
Color color;
switch (slotConfig.getFluidIO().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);
}
}

View file

@ -49,7 +49,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.lwjgl.input.Mouse;
import reborncore.api.recipe.RecipeHandler;
import reborncore.common.util.StringUtils;
@ -471,7 +470,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) {
if (GuiBase.showSlotConfig) {
if (GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE) {
return;
}
GuiScreen gui = event.getGui();
@ -486,7 +485,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void handleMouseClick(GuiScreenEvent.MouseInputEvent.Pre event) {
if (GuiBase.showSlotConfig) {
if (GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE) {
return;
}
final int eventButton = Mouse.getEventButton();

View file

@ -42,8 +42,11 @@ import reborncore.api.tile.IUpgradeable;
import reborncore.client.hud.StackInfoHUD;
import reborncore.client.multiblock.MultiblockRenderEvent;
import techreborn.blocks.BlockRubberLeaves;
import techreborn.client.*;
import techreborn.client.ClientEventHandler;
import techreborn.client.IconSupplier;
import techreborn.client.RegisterItemJsons;
import techreborn.client.gui.GuiBase;
import techreborn.client.gui.slot.GuiFluidConfiguration;
import techreborn.client.gui.slot.GuiSlotConfiguration;
import techreborn.client.keybindings.KeyBindings;
import techreborn.client.render.ModelDynamicCell;
@ -78,6 +81,7 @@ public class ClientProxy extends CommonProxy {
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);

View file

@ -32,12 +32,10 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry;
@ -45,6 +43,7 @@ import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Tank;
import techreborn.lib.ModInfo;
import javax.annotation.Nullable;
import java.util.List;
/**
@ -161,19 +160,9 @@ public class TilePump extends TilePowerAcceptor {
return tagCompound;
}
@Nullable
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
public Tank getTank() {
return tank;
}
}

View file

@ -29,9 +29,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop;
import reborncore.api.tile.IInventoryProvider;
@ -47,6 +44,7 @@ import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import javax.annotation.Nullable;
import java.util.List;
@RebornRegistry(modID = ModInfo.MOD_ID)
@ -113,22 +111,6 @@ public class TileQuantumTank extends TileLegacyMachineBase
readFromNBT(packet.getNbtCompound());
}
@Override
public boolean hasCapability(final Capability<?> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
@ -161,4 +143,10 @@ public class TileQuantumTank extends TileLegacyMachineBase
.addInventory().tile(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).addInventory()
.create(this);
}
@Nullable
@Override
public Tank getTank() {
return tank;
}
}

View file

@ -26,9 +26,7 @@ package techreborn.tiles.generator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.api.IToolDrop;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
@ -41,6 +39,8 @@ import techreborn.api.generator.FluidGeneratorRecipe;
import techreborn.api.generator.FluidGeneratorRecipeList;
import techreborn.api.generator.GeneratorRecipeHelper;
import javax.annotation.Nullable;
public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implements IToolDrop, IInventoryProvider {
private final FluidGeneratorRecipeList recipes;
@ -172,22 +172,6 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
return inventory;
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
@ -221,4 +205,10 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
public void setTankAmount(int amount){
tank.setFluidAmount(amount);
}
@Nullable
@Override
public Tank getTank() {
return tank;
}
}

View file

@ -27,10 +27,7 @@ package techreborn.tiles.multiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -46,6 +43,8 @@ import techreborn.init.ModItems;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
import javax.annotation.Nullable;
/**
* @author drcrazy
*
@ -124,22 +123,6 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
return tagCompound;
}
@Override
public boolean hasCapability(final Capability<?> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
}
// TileLegacyMachineBase
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
@ -161,4 +144,10 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
.outputSlot(2, 124, 55).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
.create(this);
}
@Nullable
@Override
public Tank getTank() {
return tank;
}
}

View file

@ -31,9 +31,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
@ -53,6 +51,8 @@ import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
import javax.annotation.Nullable;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialGrinder extends TileGenericMachine implements IContainerProvider, ITileRecipeHandler<IndustrialGrinderRecipe> {
@ -128,22 +128,6 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
return tagCompound;
}
@Override
public boolean hasCapability(final Capability<?> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
}
// TileLegacyMachineBase
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
@ -214,4 +198,10 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
}
return false;
}
@Nullable
@Override
public Tank getTank() {
return tank;
}
}

View file

@ -31,9 +31,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
@ -53,6 +51,8 @@ import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
import javax.annotation.Nullable;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialSawmill extends TileGenericMachine implements IContainerProvider, ITileRecipeHandler<IndustrialSawmillRecipe> {
@ -128,24 +128,6 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
return tagCompound;
}
@Override
public boolean hasCapability(final Capability<?> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
if (tank != null) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
}
return super.getCapability(capability, facing);
}
// TileLegacyMachineBase
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
@ -213,4 +195,10 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
}
return false;
}
@Nullable
@Override
public Tank getTank() {
return tank;
}
}