mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
refactor 6
This commit is contained in:
1 parent
5b62c4fdc8
commit
8d072f0c89
78 files changed
+525
-882
No files matched your search
@@ -9,7 +9,7 @@ import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.inventory.slot.ISlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketEncodePattern;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
@@ -82,8 +82,8 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
}
|
||||
|
||||
public void drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotFluid) {
|
||||
IAEItemStack stack = ((SlotFluid) slot).getAeStack();
|
||||
if (slot instanceof ISlotFluid) {
|
||||
IAEItemStack stack = ((ISlotFluid) slot).getAeStack();
|
||||
super.func_146977_a(new SlotSingleItem(slot));
|
||||
if (stack == null) return;
|
||||
IAEItemStack fake = stack.copy();
|
||||
|
||||
@@ -14,13 +14,15 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -29,7 +31,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -41,10 +42,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private TileLevelMaintainer tile;
|
||||
private FCGuiTextField input;
|
||||
private int lastWorkingTick;
|
||||
private final int interval = 20;
|
||||
private int refreshTick;
|
||||
private final CoFHFontRenderer render;
|
||||
|
||||
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
@@ -52,12 +52,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.cont = (ContainerLevelMaintainer) inventorySlots;
|
||||
this.xSize = 195;
|
||||
this.ySize = 214;
|
||||
this.tile = tile;
|
||||
this.render = new CoFHFontRenderer(
|
||||
Minecraft.getMinecraft().gameSettings,
|
||||
TEX_BG,
|
||||
Minecraft.getMinecraft().getTextureManager(),
|
||||
true);
|
||||
this.refreshTick = 0;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list) {
|
||||
@@ -81,7 +81,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
this.lastWorkingTick = this.refreshTick;
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
component[i] = new Component(
|
||||
new Widget(
|
||||
@@ -104,6 +104,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
this.refreshTick++;
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
for (Component com : this.component) {
|
||||
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
|
||||
@@ -116,10 +117,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
int tick = MinecraftServer.getServer().getTickCounter();
|
||||
int tick = this.refreshTick;
|
||||
int interval = 20;
|
||||
if (tick > lastWorkingTick + interval && this.input == null) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
lastWorkingTick = this.refreshTick;
|
||||
}
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
this.component[i].draw();
|
||||
@@ -139,7 +141,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
public boolean drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotFake) {
|
||||
IAEItemStack stack = ((ContainerLevelMaintainer.FakeSlot) slot).getAeStack();
|
||||
IAEItemStack stack = ((SlotFluidConvertingFake) slot).getAeStack();
|
||||
super.func_146977_a(new SlotSingleItem(slot));
|
||||
if (stack == null) return true;
|
||||
IAEItemStack fake = stack.copy();
|
||||
@@ -206,8 +208,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof ContainerLevelMaintainer.FakeSlot
|
||||
&& this.cont.getPlayerInv().getItemStack() != null) {
|
||||
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() != null) {
|
||||
this.component[slot.getSlotIndex()]
|
||||
.getQty()
|
||||
.textField
|
||||
@@ -252,7 +253,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
|
||||
for (ContainerLevelMaintainer.FakeSlot slot : this.cont.getRequestSlots()) {
|
||||
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
|
||||
if (getSlotArea(slot).contains(mouseX, mouseY)) {
|
||||
slot.putStack(draggedStack);
|
||||
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
|
||||
@@ -313,7 +314,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
private boolean send(Widget widget) {
|
||||
if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) {
|
||||
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
|
||||
if (!widget.textField.getText().isEmpty()
|
||||
&& widget.textField.getText().matches("^[0-9]+")) {
|
||||
String str = widget.textField.getText().replaceAll("^(0+)", "");
|
||||
|
||||
+1
-2
@@ -29,7 +29,6 @@ import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.SPacketMEInventoryUpdate;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -281,7 +280,7 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
|
||||
this.getInventoryPlayer().player,
|
||||
getWorld(),
|
||||
new BlockPos(this.getOpenContext().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getOpenContext().getSide())),
|
||||
Objects.requireNonNull(this.getOpenContext().getSide()),
|
||||
originalGui);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-61
@@ -3,10 +3,8 @@ package com.glodblock.github.client.gui.container;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
@@ -14,21 +12,17 @@ import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.inventory.IPatternConsumer;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
|
||||
|
||||
@@ -171,58 +165,4 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
|
||||
dest.setStack(i, src[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotFluidConvertingFake extends SlotFake implements SlotFluid {
|
||||
|
||||
private final AeStackInventory<IAEItemStack> inv;
|
||||
|
||||
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.inv = inv.getAeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack stack) {
|
||||
inv.setStack(getSlotIndex(), AEItemStack.create(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
|
||||
inv.setStack(getSlotIndex(), stack);
|
||||
}
|
||||
|
||||
public void putConvertedStack(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
setAeStack(null, false);
|
||||
return;
|
||||
} else if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(stack)) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
putStack(stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IAEItemStack getAeStack() {
|
||||
return inv.getStack(getSlotIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-11
@@ -4,6 +4,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -11,14 +12,14 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
private final TileLevelMaintainer tile;
|
||||
private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT];
|
||||
private final SlotFluidConvertingFake[] requestSlots = new SlotFluidConvertingFake[TileLevelMaintainer.REQ_COUNT];
|
||||
|
||||
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
|
||||
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
|
||||
FakeSlot slot = new FakeSlot(request, y, 27, 20 + y * 19);
|
||||
SlotFluidConvertingFake slot = new SlotFluidConvertingFake(request, y, 27, 20 + y * 19);
|
||||
addSlotToContainer(slot);
|
||||
requestSlots[y] = slot;
|
||||
}
|
||||
@@ -29,13 +30,13 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public FakeSlot[] getRequestSlots() {
|
||||
public SlotFluidConvertingFake[] getRequestSlots() {
|
||||
return this.requestSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
|
||||
for (FakeSlot slot : this.getRequestSlots()) {
|
||||
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
|
||||
if (!slot.getHasStack()) {
|
||||
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
|
||||
break;
|
||||
@@ -44,11 +45,4 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake {
|
||||
|
||||
public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user