Compare commits

..
Author SHA1 Message Date
Martin Robertz 02b714cbf9 Merge remote-tracking branch 'asdflj/master' into dev 2023-02-24 18:30:25 +01:00
26 changed files with 193 additions and 810 deletions

No files matched your search

@@ -3,13 +3,11 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Upgrades;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.NameConst;
@@ -60,13 +58,4 @@ public class GuiFluidIO extends GuiUpgradeable {
this.schedulingMode.set(this.cvb.getSchedulingMode());
}
}
@Override
protected void handleButtonVisibility() {
super.handleButtonVisibility();
if (this.schedulingMode != null) {
this.schedulingMode.setVisibility(
this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof PartFluidExportBus);
}
}
}
@@ -16,6 +16,7 @@ import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.*;
import appeng.client.me.ClientDCInternalInv;
@@ -41,7 +42,6 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.google.common.collect.HashMultimap;
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
@@ -52,7 +52,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<ClientDCInternalInv, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
@@ -352,15 +352,10 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
@Override
protected void actionPerformed(final GuiButton btn) {
if (guiButtonHashMap.containsKey(btn)) {
Util.DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
if (btn instanceof GuiFCImgButton) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketRenamer(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
blockPos.getSide()));
new CPacketRenamer(blockPos.x, blockPos.y, blockPos.z, blockPos.getDimension(), blockPos.side));
} else {
WorldCoord blockPos2 = new WorldCoord(
@@ -502,6 +497,17 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
return false;
}
private static class DimensionalCoordSide extends DimensionalCoord {
private ForgeDirection side = ForgeDirection.UNKNOWN;
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side) {
super(_x, _y, _z, _dim);
this.side = side;
}
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
@@ -521,9 +527,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
int Z = invData.getInteger("z");
int dim = invData.getInteger("dim");
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
blockPosHashMap.put(
current,
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
final String which = Integer.toString(x);
@@ -1,76 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerRenamer;
import com.glodblock.github.network.CPacketRenamer;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
private MEGuiTextField textField;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.xSize = 256;
this.textField = new MEGuiTextField(230, 12);
this.textField.setMaxStringLength(32);
}
@Override
public void initGui() {
super.initGui();
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(GuiText.Renamer.getLocal(), 12, 8, GuiColors.RenamerTitle.getColor());
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/renamer.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.textField.drawTextBox();
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
this.textField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (key == 28) { // Enter
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(this.textField.getText()));
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
public boolean isOverTextField(final int mousex, final int mousey) {
return textField.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
public void postUpdate(String text) {
this.textField.setText(text);
}
}
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
@@ -36,11 +35,6 @@ public class ContainerFluidIO extends FCContainerFluidConfigurable {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE));
}
}
public void setSchedulingMode(final SchedulingMode schedulingMode) {
this.schedulingMode = schedulingMode;
}
}
@@ -18,6 +18,8 @@ import org.apache.commons.lang3.tuple.MutablePair;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -26,7 +28,6 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
@@ -41,6 +42,7 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
@@ -59,28 +61,27 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getFluidInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
if (monitorable instanceof IFluidPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = monitorable.getFluidInventory();
this.monitor.addListener(this, null);
this.setPowerSource((IEnergySource) monitorable);
this.setValidContainer(false);
}
} else {
this.monitor = null;
@@ -150,6 +151,11 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
}
@Override
protected boolean isInvalid() {
return this.monitor != this.host.getFluidInventory();
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
@@ -218,38 +224,26 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
if (fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
// The real result may don't match simulation result.
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) continue;
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (fillStack.right.getItem() instanceof IFluidContainerItem) {
IAEFluidStack real = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if (real == null) continue;
// Refill the container
out = fluidContainer.copy();
out.stackSize = 1;
fillStack = Util.FluidUtil.fillStack(out, real.getFluidStack());
fillStack.right.stackSize = (int) (real.getStackSize() / fillStack.left);
out.stackSize = fillStack.right.stackSize;
if ((int) (real.getStackSize() % fillStack.left) > 0) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) > 0) {
this.dropItem(
Util.FluidUtil.setFluidContainerAmount(
fillStack.right,
(int) (real.getStackSize() % fillStack.left)),
(int) (tmp.getStackSize() % fillStack.left)),
1);
out.stackSize++;
}
} else if (FluidContainerRegistry.isContainer(fillStack.right)) {
IAEFluidStack real = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if (real == null) continue;
// Refill the container
out = fluidContainer.copy();
out.stackSize = 1;
fillStack = Util.FluidUtil.fillStack(out, real.getFluidStack());
fillStack.right.stackSize = (int) (real.getStackSize() / fillStack.left);
out.stackSize = fillStack.right.stackSize;
toExtract.setStackSize((long) fillStack.right.stackSize * fillStack.left);
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
this.dropItem(fillStack.right);
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// add fluid to ae network
AEFluidStack fluidStack = Util.getAEFluidFromItem(fluidContainer);
@@ -9,6 +9,8 @@ import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -17,7 +19,6 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -42,29 +43,26 @@ public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getItemInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = monitorable.getItemInventory();
this.monitor = monitorable.getItemInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
this.setPowerSource((IEnergySource) monitorable);
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
}
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = null;
@@ -1,13 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
public class ContainerRenamer extends AEBaseContainer {
public ContainerRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
}
@@ -112,7 +112,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
protected abstract void processItemList();
protected boolean isInvalid() {
return this.monitor == null;
return this.monitor != this.host.getItemInventory();
}
protected void updatePowerStatus() {
@@ -1,7 +1,6 @@
package com.glodblock.github.common.parts;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
@@ -27,7 +26,6 @@ import appeng.core.AELog;
import appeng.helpers.MultiCraftingTracker;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
@@ -45,9 +43,6 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
private final BaseActionSource source;
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
private int nextSlot = 0;
private long fluidToSend = 1000;
private boolean didSomething;
public PartFluidExportBus(ItemStack is) {
super(is);
@@ -78,33 +73,12 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return this.getProxy().isActive();
}
private int getStartingSlot(final SchedulingMode schedulingMode, final int x) {
if (schedulingMode == SchedulingMode.RANDOM) {
return Platform.getRandom().nextInt(this.availableSlots());
}
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
return (this.nextSlot + x) % this.availableSlots();
}
return x;
}
private int availableSlots() {
return Math.min(1 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 4, this.getInv().getSizeInventory());
}
private IInventory getInv() {
return this.getInventoryByName("config");
}
@Override
protected TickRateModulation doBusWork() {
if (!this.canDoBusWork()) {
return TickRateModulation.IDLE;
}
this.didSomething = false;
this.fluidToSend = this.calculateAmountToSend();
final TileEntity te = this.getConnectedTE();
if (te instanceof IFluidHandler) {
@@ -113,11 +87,10 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
final ICraftingGrid cg = this.getProxy().getCrafting();
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
int i;
for (i = 0; i < this.availableSlots() && this.fluidToSend > 0; i++) {
final int slotToExport = this.getStartingSlot(this.getSchedulingMode(), i);
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
IAEFluidStack fluid = AEFluidStack
.create(ItemFluidPacket.getFluidStack(getInv().getStackInSlot(slotToExport)));
.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if (fluid != null) {
boolean isAllowed = true;
@@ -137,18 +110,20 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
this.source);
}
int space = fh.fill(this.getSide().getOpposite(), toExtract.getFluidStack(), false);
toExtract.setStackSize(space);
final IAEFluidStack real = inv.extractItems(toExtract, Actionable.MODULATE, this.source);
if (real != null && isAllowed) {
int realInserted = fh.fill(this.getSide().getOpposite(), real.getFluidStack(), true);
if (realInserted < real.getStackSize()) {
toExtract.setStackSize(real.getStackSize() - realInserted);
inv.injectItems(toExtract, Actionable.MODULATE, this.source);
final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source);
if (out != null && isAllowed) {
int wasInserted = fh.fill(this.getSide().getOpposite(), out.getFluidStack(), true);
if (wasInserted > 0) {
toExtract.setStackSize(wasInserted);
inv.extractItems(toExtract, Actionable.MODULATE, this.source);
return TickRateModulation.FASTER;
}
this.fluidToSend -= realInserted;
didSomething = true;
} else if (this.isCraftingEnabled()) {
}
if (this.isCraftingEnabled()) {
this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
@@ -161,8 +136,8 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
}
}
}
this.updateSchedulingMode(this.getSchedulingMode(), i);
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
return TickRateModulation.SLOWER;
} catch (GridAccessException e) {
// Ignore
}
@@ -171,12 +146,6 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return TickRateModulation.SLEEP;
}
private void updateSchedulingMode(final SchedulingMode schedulingMode, final int x) {
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
this.nextSlot = (this.nextSlot + x) % this.availableSlots();
}
}
@Override
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(4, 4, 12, 12, 12, 14);
@@ -247,10 +216,6 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
}
public SchedulingMode getSchedulingMode() {
return (SchedulingMode) this.getConfigManager().getSetting(Settings.SCHEDULING_MODE);
}
private boolean craftOnly() {
return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES;
}
@@ -1,17 +1,14 @@
package com.glodblock.github.common.tile;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.util.BlockPos;
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
@@ -29,7 +26,6 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return this;
}
};
private boolean hasUpdate;
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
@@ -195,40 +191,6 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return (float) this.tank.getFluidAmount() / this.tank.getCapacity();
}
private void onComparatorUpdate(World world, int x, int y, int z, Block block) {
world.func_147453_f(x, y, z, block);
}
@Override
public void updateEntity() {
super.updateEntity();
if (this.tank.getFluid() != null) {
TileCertusQuartzTank below = getTankBelow(this);
if (below != null) {
FluidStack filled = this.tank.getFluid().copy();
filled.amount = below.fill(this.tank.getFluid(), true, true);
if (filled.amount >= 0) {
this.drain(filled, true, true);
this.hasUpdate = true;
below.hasUpdate = true;
}
}
}
if (this.hasUpdate) {
onComparatorUpdate(this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
this.hasUpdate = false;
}
}
private TileCertusQuartzTank getTankBelow(TileEntity tile) {
TileEntity tank = new BlockPos(tile).getOffSet(0, -1, 0).getTileEntity();
if (tank != null && tank instanceof TileCertusQuartzTank) {
return (TileCertusQuartzTank) tank;
}
return null;
}
public FluidTankInfo[] getTankInfo(boolean goToMainTank) {
if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() };
@@ -250,12 +212,12 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
break;
}
yOff -= 1;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
yOff = 0;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
mainTank = (TileCertusQuartzTank) offTE;
if (mainTank.getFluid() == null || getFluid() == null || mainTank.getFluid() == getFluid()) {
if (mainTank.getFluid() == null || mainTank.getFluid() == getFluid()) {
FluidTankInfo info = mainTank.getTankInfo(false)[0];
if (info != null) {
capacity += info.capacity;
@@ -264,7 +226,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid();
}
}
offTE = new BlockPos(offTE).getOffSet(0, 1, 0).getTileEntity();
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
continue;
}
}
@@ -311,8 +274,4 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
public void writeToNBTWithoutCoords(NBTTagCompound tag) {
this.tank.writeToNBT(tag);
}
public FluidTankInfo[] getInternalFluid() {
return this.getTankInfo(true);
}
}
@@ -4,8 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode;
@@ -31,8 +30,7 @@ import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
public class TileFluidPacketDecoder extends AENetworkTile
implements IGridTickable, IAEAppEngInventory, IInventory, IFluidHandler {
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory, IInventory {
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
private final BaseActionSource ownActionSource = new MachineSource(this);
@@ -166,68 +164,4 @@ public class TileFluidPacketDecoder extends AENetworkTile
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return stack.getItem() instanceof ItemFluidPacket;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack requestFluid, boolean doDrain) {
return this.drain(requestFluid, doDrain);
}
private FluidStack drain(FluidStack requestFluid, boolean doDrain) {
if (requestFluid == null || requestFluid.amount <= 0) return null;
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket != null) {
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
if (fs == null) return null;
if (fs.isFluidEqual(requestFluid)) {
if (fs.amount > requestFluid.amount) {
fs.amount -= requestFluid.amount;
if (doDrain) this.inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(fs));
return requestFluid;
} else {
if (doDrain) this.inventory.setInventorySlotContents(0, null);
return fs;
}
}
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket != null) {
FluidStack requestFluid = ItemFluidPacket.getFluidStack(fluidPacket);
if (requestFluid == null) return null;
requestFluid.amount = maxDrain;
return this.drain(requestFluid, doDrain);
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return false;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket == null) {
return new FluidTankInfo[0];
} else {
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
if (fs == null) return new FluidTankInfo[0];
return new FluidTankInfo[] { new FluidTankInfo(fs, fs.amount) };
}
}
}
@@ -40,6 +40,9 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.core.sync.packets.PacketCompressedNBT":
tform = PacketCompressedNBTTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiRenamer":
tform = GuiRenamerTransformer.INSTANCE;
break;
default:
return code;
}
@@ -2,9 +2,16 @@ package com.glodblock.github.coremod.hooker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -19,4 +26,12 @@ public class CoreModHooksClient {
}
}
public static void reopenInterfaceTerminal() {
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
ItemStack c = p.getCurrentEquippedItem();
if (c.getItem() instanceof ItemWirelessInterfaceTerminal || c.getItem() instanceof ItemWirelessUltraTerminal) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.WIRELESS_INTERFACE_TERMINAL, true));
}
}
}
@@ -0,0 +1,59 @@
package com.glodblock.github.coremod.transform;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import com.glodblock.github.coremod.FCClassTransformer;
public class GuiRenamerTransformer extends FCClassTransformer.ClassMapper {
public static final GuiRenamerTransformer INSTANCE = new GuiRenamerTransformer();
private GuiRenamerTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new GuiRenamerTransformer.TransformGuiRenamer(Opcodes.ASM5, downstream);
}
private static class TransformGuiRenamer extends ClassVisitor {
TransformGuiRenamer(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("keyTyped")) {
return new GuiRenamerTransformer.TransformKeyTyped(
api,
super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformKeyTyped extends MethodVisitor {
TransformKeyTyped(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
super.visitMethodInsn(opcode, owner, name, desc, itf);
if (owner.equals("net/minecraft/client/entity/EntityClientPlayerMP") && name.equals("closeScreen")) {
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooksClient",
"reopenInterfaceTerminal",
"()V",
false);
}
}
}
}
@@ -15,14 +15,6 @@ public class Tooltip {
return String.format("%s: %s mB", name, NumberFormat.getInstance().format(amount));
}
public static String fluidFormat(String name, long amount, long capacity) {
return String.format(
"%s: %s mB / %s mB",
name,
NumberFormat.getInstance().format(amount),
NumberFormat.getInstance().format(capacity));
}
public static String partFluidBusFormat(int amount) {
return String
.format("%s: %s mB/t", I18n.format(NameConst.WAILA_SPEED), NumberFormat.getInstance().format(amount));
@@ -1,71 +0,0 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.glodblock.github.crossmod.waila.vanilla.FluidInvWailaDataProvider;
import com.google.common.collect.Lists;
public class VanillaTileWailaDataProvider implements IWailaDataProvider {
private final List<IWailaDataProvider> providers;
public VanillaTileWailaDataProvider() {
final IWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
this.providers = Lists.newArrayList(fluidInv);
}
@Override
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaHead(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaBody(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaTail(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
for (final IWailaDataProvider provider : this.providers) {
provider.getNBTData(player, te, tag, world, x, y, z);
}
return tag;
}
}
@@ -2,9 +2,6 @@ package com.glodblock.github.crossmod.waila;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import net.minecraft.tileentity.TileEntity;
import appeng.api.parts.IPartHost;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
@@ -26,10 +23,5 @@ public class WailaInit {
final IWailaDataProvider tile = new TileWailaDataProvider();
registrar.registerBodyProvider(tile, AEBaseTile.class);
registrar.registerNBTProvider(tile, AEBaseTile.class);
final IWailaDataProvider vanillaTile = new VanillaTileWailaDataProvider();
registrar.registerBodyProvider(vanillaTile, TileEntity.class);
registrar.registerNBTProvider(vanillaTile, TileEntity.class);
}
}
@@ -1,51 +0,0 @@
package com.glodblock.github.crossmod.waila.vanilla;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidTankInfo;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.crossmod.waila.Tooltip;
import com.glodblock.github.util.Util;
public class FluidInvWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCertusQuartzTank) {
if (accessor.getNBTData().hasKey("fluidInv")) {
NBTTagCompound data = (NBTTagCompound) accessor.getNBTData().getTag("fluidInv");
for (FluidTankInfo info : Util.FluidUtil.fluidTankInfoReadFromNBT(data)) {
if (info.fluid == null) continue;
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
if (te instanceof TileCertusQuartzTank) {
NBTTagCompound data = new NBTTagCompound();
Util.FluidUtil.fluidTankInfoWriteToNBT(((TileCertusQuartzTank) te).getInternalFluid(), data);
tag.setTag("fluidInv", data);
te.writeToNBT(tag);
}
return tag;
}
}
@@ -27,18 +27,6 @@ import com.google.common.collect.ImmutableList;
public enum GuiType {
RENAMER(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerRenamer(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiRenamer(player.inventory, inv);
}
}),
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
@Override
@@ -1,10 +1,4 @@
package com.glodblock.github.inventory.item;
import com.glodblock.github.util.Util;
public interface IWirelessInterfaceTerminal extends IWirelessTerminal {
void setClickedInterface(Util.DimensionalCoordSide tile);
Util.DimensionalCoordSide getClickedInterface();
}
@@ -1,7 +1,5 @@
package com.glodblock.github.inventory.item;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -12,7 +10,6 @@ import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
@@ -22,38 +19,18 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.util.Util;
public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final IGridNode grid;
private Util.DimensionalCoordSide tile;
public WirelessInterfaceTerminalInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
Objects.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
readFromNBT();
}
public void readFromNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
if (data.hasKey("clickedInterface")) {
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
}
}
public void writeToNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
NBTTagCompound tileMsg = new NBTTagCompound();
tile.writeToNBT(tileMsg);
data.setTag("clickedInterface", tileMsg);
}
@Override
@@ -131,15 +108,4 @@ public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTer
ItemStack newStack) {
}
@Override
public void setClickedInterface(Util.DimensionalCoordSide tile) {
this.tile = tile;
this.writeToNBT();
}
@Override
public Util.DimensionalCoordSide getClickedInterface() {
return this.tile;
}
}
@@ -54,8 +54,6 @@ public class ChannelLoader implements Runnable {
.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
FluidCraft.proxy.netHandler
.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
FluidCraft.proxy.netHandler
.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
}
public static void sendPacketToAllPlayers(Packet packet, World world) {
@@ -1,23 +1,12 @@
package com.glodblock.github.network;
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.getGuis;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.container.AEBaseContainer;
import appeng.helpers.ICustomNameObject;
import appeng.tile.networking.TileCableBus;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -30,28 +19,10 @@ public class CPacketRenamer implements IMessage {
private int z;
private int dim;
private ForgeDirection side;
private Action action;
private String text;
public enum Action {
OPEN,
GET_TEXT,
SET_TEXT,
}
public CPacketRenamer() {}
public CPacketRenamer(String text) {
this.action = Action.SET_TEXT;
this.text = text;
}
public CPacketRenamer(Action a) {
this.action = a;
}
public CPacketRenamer(int x, int y, int z, int dim, ForgeDirection side) {
this.action = Action.OPEN;
this.x = x;
this.y = y;
this.z = z;
@@ -61,114 +32,31 @@ public class CPacketRenamer implements IMessage {
@Override
public void fromBytes(ByteBuf buf) {
this.action = Action.values()[buf.readInt()];
if (this.action == Action.OPEN) {
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.dim = buf.readInt();
this.side = ForgeDirection.getOrientation(buf.readInt());
} else if (this.action == Action.SET_TEXT) {
int leName = buf.readInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < leName; i++) {
sb.append(buf.readChar());
}
this.text = sb.toString();
}
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.dim = buf.readInt();
this.side = ForgeDirection.getOrientation(buf.readInt());
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.action.ordinal());
if (this.action == Action.OPEN) {
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeInt(this.dim);
buf.writeInt(side.ordinal());
} else if (this.action == Action.SET_TEXT) {
buf.writeInt(this.text.length());
for (int i = 0; i < this.text.length(); i++) {
buf.writeChar(this.text.charAt(i));
}
}
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeInt(this.dim);
buf.writeInt(side.ordinal());
}
public static class Handler implements IMessageHandler<CPacketRenamer, IMessage> {
private String getName(TileEntity tile, ForgeDirection side) {
if (tile instanceof TileCableBus) {
return ((ICustomNameObject) ((TileCableBus) tile).getPart(side)).getCustomName();
} else {
return ((ICustomNameObject) tile).getCustomName();
}
}
private void setName(TileEntity tile, ForgeDirection side, String text) {
if (tile instanceof TileCableBus) {
((ICustomNameObject) ((TileCableBus) tile).getPart(side)).setCustomName(text);
} else {
((ICustomNameObject) tile).setCustomName(text);
}
}
@Override
public IMessage onMessage(CPacketRenamer message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
AEBaseContainer con = (AEBaseContainer) player.openContainer;
TileEntity tile;
if (message.action == Action.OPEN) {
tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
if (tile != null && con.getTarget() instanceof IWirelessInterfaceTerminal
&& tile instanceof ICustomNameObject) {
String name = getName(tile, message.side);
((IWirelessInterfaceTerminal) con.getTarget()).setClickedInterface(
new Util.DimensionalCoordSide(
message.x,
message.y,
message.z,
message.dim,
message.side,
name));
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
1),
message.side,
GuiType.RENAMER);
}
} else {
if (con.getTarget() instanceof IWirelessInterfaceTerminal) {
Util.DimensionalCoordSide intMsg = ((IWirelessInterfaceTerminal) con.getTarget())
.getClickedInterface();
tile = DimensionManager.getWorld(intMsg.getDimension()).getTileEntity(intMsg.x, intMsg.y, intMsg.z);
if (message.action == Action.GET_TEXT) {
FluidCraft.proxy.netHandler
.sendTo(new SPacketStringUpdate(this.getName(tile, intMsg.getSide())), player);
} else {
this.setName(tile, intMsg.getSide(), message.text);
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(
getGuis().indexOf(
GuiType.valueOf(
GuiType.WIRELESS_INTERFACE_TERMINAL.toString())),
Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
GuiType.WIRELESS_INTERFACE_TERMINAL);
}
}
TileEntity tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
if (tile != null) {
Platform.openGUI(player, tile, message.side, GuiBridge.GUI_RENAMER);
}
return null;
}
}
@@ -1,61 +0,0 @@
package com.glodblock.github.network;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import com.glodblock.github.client.gui.*;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class SPacketStringUpdate implements IMessage {
private String text;
private int slot;
public SPacketStringUpdate() {}
public SPacketStringUpdate(String text, int slot) {
this.text = text;
this.slot = slot;
}
public SPacketStringUpdate(String text) {
this.text = text;
this.slot = 0;
}
@Override
public void fromBytes(ByteBuf buf) {
this.slot = buf.readInt();
int leName = buf.readInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < leName; i++) {
sb.append(buf.readChar());
}
this.text = sb.toString();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.slot);
buf.writeInt(this.text.length());
for (int i = 0; i < this.text.length(); i++) {
buf.writeChar(this.text.charAt(i));
}
}
public static class Handler implements IMessageHandler<SPacketStringUpdate, IMessage> {
@Override
public IMessage onMessage(SPacketStringUpdate message, MessageContext ctx) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiRenamer) {
((GuiRenamer) gs).postUpdate(message.text);
}
return null;
}
}
}
@@ -40,10 +40,6 @@ public class BlockPos {
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ, this.w);
}
public BlockPos getOffSet(int x, int y, int z) {
return new BlockPos(this.x + x, this.y + y, this.z + z, this.w);
}
public TileEntity getTileEntity() {
if (w != null) {
return w.getTileEntity(x, y, z);
@@ -3,8 +3,6 @@ package com.glodblock.github.util;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
@@ -33,7 +31,6 @@ import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.container.AEBaseContainer;
import appeng.items.tools.powered.ToolWirelessTerminal;
@@ -113,11 +110,10 @@ public final class Util {
}
public static IMEInventoryHandler<?> getWirelessInv(ItemStack is, EntityPlayer player, StorageChannel channel) {
if (Platform.isClient()) return new NullInventory<>();
IGridNode gridNode = getWirelessGrid(is);
if (gridNode == null) return null;
if (gridNode == null) return new NullInventory<>();
IGrid grid = gridNode.getGrid();
if (grid == null) return null;
if (grid == null) return new NullInventory<>();
boolean canConnect = false;
if (hasInfinityBoosterCard(is)) {
canConnect = true;
@@ -145,7 +141,7 @@ public final class Util {
}
}
}
return null;
return new NullInventory<>();
}
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
@@ -417,36 +413,6 @@ public final class Util {
public static class FluidUtil {
public static void fluidTankInfoWriteToNBT(FluidTankInfo[] infos, NBTTagCompound data) {
int i = 0;
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.amount > 0) {
NBTTagCompound fs = new NBTTagCompound();
info.fluid.writeToNBT(fs);
fs.setInteger("capacity", info.capacity);
data.setTag("#" + i, fs);
}
i++;
}
data.setInteger("fluidInvSize", i);
}
public static FluidTankInfo[] fluidTankInfoReadFromNBT(NBTTagCompound data) {
int i = 0;
List<FluidTankInfo> infos = new ArrayList<>();
while (data.hasKey("fluidInvSize") && i < data.getInteger("fluidInvSize")) {
if (data.hasKey("#" + i)) {
NBTTagCompound tag = (NBTTagCompound) data.getTag("#" + i);
FluidStack fs = FluidStack.loadFluidStackFromNBT(tag);
infos.add(new FluidTankInfo(fs, tag.getInteger("capacity")));
} else {
infos.add(new FluidTankInfo(null, 0));
}
i++;
}
return infos.toArray(new FluidTankInfo[0]);
}
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
}
@@ -587,43 +553,4 @@ public final class Util {
return null;
}
}
public static class DimensionalCoordSide extends DimensionalCoord {
private ForgeDirection side = ForgeDirection.UNKNOWN;
private final String name;
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side,
String name) {
super(_x, _y, _z, _dim);
this.side = side;
this.name = name;
}
public String getName() {
return name;
}
public ForgeDirection getSide() {
return this.side;
}
@Override
public void writeToNBT(NBTTagCompound data) {
data.setInteger("side", this.side.ordinal());
data.setString("name", this.name);
super.writeToNBT(data);
}
public static DimensionalCoordSide readFromNBT(final NBTTagCompound data) {
return new DimensionalCoordSide(
data.getInteger("x"),
data.getInteger("y"),
data.getInteger("z"),
data.getInteger("dim"),
ForgeDirection.getOrientation(data.getInteger("side")),
data.getString("name"));
}
}
}