mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
Merge branch 'master' of https://github.com/CrazyPants/EnderIO.git
This commit is contained in:
commit
d6d32becc9
16 files changed
+260
-164
No files matched your search
@@ -390,7 +390,7 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putStack(ItemStack stack) {
|
||||
public void putStack(ItemStack stack) {
|
||||
if(stack != null) {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
@@ -400,7 +400,7 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getStack() {
|
||||
public ItemStack getStack() {
|
||||
return items[slot];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface IMEConduit extends IConduit {
|
||||
|
||||
boolean isDense();
|
||||
|
||||
int getChannelsInUse();
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPart;
|
||||
@@ -121,6 +122,18 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChannelsInUse() {
|
||||
int channelsInUse = 0;
|
||||
IGridNode node = getNode();
|
||||
if(node != null) {
|
||||
for (IGridConnection gc : node.getConnections()) {
|
||||
channelsInUse = Math.max(channelsInUse, gc.getUsedChannels());
|
||||
}
|
||||
}
|
||||
return channelsInUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "appliedenergistics2")
|
||||
public boolean canConnectToExternal(ForgeDirection dir, boolean ignoreDisabled) {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package crazypants.enderio.machine.crafter;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class BlockCrafter extends AbstractMachineBlock<TileCrafter> {
|
||||
|
||||
public static BlockCrafter create() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketCrafter.class,PacketCrafter.class,PacketHandler.nextID(), Side.SERVER);
|
||||
BlockCrafter res = new BlockCrafter();
|
||||
res.init();
|
||||
return res;
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
package crazypants.enderio.machine.crafter;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.gui.TemplateSlot;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.GhostSlot;
|
||||
|
||||
public class ContainerCrafter extends AbstractMachineContainer {
|
||||
|
||||
private TileCrafter crafter;
|
||||
private DummyCraftingGrid craftingGrid;
|
||||
private final TileCrafter crafter;
|
||||
|
||||
public ContainerCrafter(InventoryPlayer playerInv, TileCrafter te) {
|
||||
super(playerInv, te);
|
||||
addCrafterSlots();
|
||||
crafter = (TileCrafter) tileEntity;
|
||||
}
|
||||
|
||||
private void addCrafterSlots() {
|
||||
crafter = (TileCrafter) tileEntity;
|
||||
craftingGrid = crafter.craftingGrid;
|
||||
|
||||
public void addCrafterSlots(List<GhostSlot> ghostSlots) {
|
||||
int topY = 16;
|
||||
int leftX = 31;
|
||||
int index = 0;
|
||||
@@ -32,12 +29,12 @@ public class ContainerCrafter extends AbstractMachineContainer {
|
||||
for (int col = 0; col < 3; ++col) {
|
||||
int x = leftX + col * 18;
|
||||
int y = topY + row * 18;
|
||||
addSlotToContainer(new DummySlot(craftingGrid, index, x, y));
|
||||
ghostSlots.add(new DummySlot(index, x, y));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
addSlotToContainer(new DummySlot(craftingGrid, 9, 90, 34));
|
||||
|
||||
ghostSlots.add(new DummySlot(9, 90, 34));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,19 +42,17 @@ public class ContainerCrafter extends AbstractMachineContainer {
|
||||
return new Point(30, 84);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getUpgradeOffset() {
|
||||
return new Point(6, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
|
||||
int topY = 16;
|
||||
int leftX = 31;
|
||||
int leftX = 113;
|
||||
int index = 0;
|
||||
|
||||
leftX = 113;
|
||||
index = 0;
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int col = 0; col < 3; ++col) {
|
||||
int x = leftX + col * 18;
|
||||
@@ -73,18 +68,6 @@ public class ContainerCrafter extends AbstractMachineContainer {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3,
|
||||
EntityPlayer par4EntityPlayer) {
|
||||
if(par1 >= 0 && par1 < inventorySlots.size()) {
|
||||
Slot slot = getSlot(par1);
|
||||
if(slot.getHasStack() && slot instanceof DummySlot) {
|
||||
slot.putStack(null);
|
||||
}
|
||||
}
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
}
|
||||
|
||||
private class InputSlot extends Slot {
|
||||
|
||||
@@ -103,35 +86,30 @@ public class ContainerCrafter extends AbstractMachineContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private class DummySlot extends TemplateSlot {
|
||||
private class DummySlot extends GhostSlot {
|
||||
private final int slotIndex;
|
||||
|
||||
public DummySlot(IInventory inventory, int slotIndex, int x, int y) {
|
||||
super(inventory, slotIndex, x, y);
|
||||
public DummySlot(int slotIndex, int x, int y) {
|
||||
this.slotIndex = slotIndex;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return true;
|
||||
public ItemStack getStack() {
|
||||
return crafter.craftingGrid.getStackInSlot(slotIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack) {
|
||||
if(par1ItemStack != null) {
|
||||
par1ItemStack.stackSize = 0;
|
||||
public void putStack(ItemStack stack) {
|
||||
if(slotIndex >= 9) {
|
||||
return;
|
||||
}
|
||||
inventory.setInventorySlotContents(slotIndex, par1ItemStack);
|
||||
onSlotChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
crafter.updateCraftingOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return false;
|
||||
if(stack != null) {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToServer(PacketCrafter.setSlot(crafter, slotIndex, stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,19 @@ import org.lwjgl.opengl.GL11;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.ToggleButtonEIO;
|
||||
import crazypants.enderio.machine.IItemBuffer;
|
||||
import crazypants.enderio.machine.PacketItemBuffer;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.GhostSlot;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GuiCrafter extends GuiPoweredMachineBase<TileCrafter> {
|
||||
|
||||
private ToggleButtonEIO bufferSizeB;
|
||||
private final ToggleButtonEIO bufferSizeB;
|
||||
|
||||
public GuiCrafter(InventoryPlayer par1InventoryPlayer, TileCrafter te) {
|
||||
super(te, new ContainerCrafter(par1InventoryPlayer, te));
|
||||
@@ -38,6 +40,22 @@ public class GuiCrafter extends GuiPoweredMachineBase<TileCrafter> {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
bufferSizeB.onGuiInit();
|
||||
((ContainerCrafter) inventorySlots).addCrafterSlots(ghostSlots);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int button, long par4) {
|
||||
if(!ghostSlots.isEmpty()) {
|
||||
GhostSlot slot = getGhostSlot(mouseX, mouseY);
|
||||
if(slot != null) {
|
||||
ItemStack st = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
|
||||
// don't replace already set slots while dragging an item
|
||||
if(st == null || slot.getStack() == null) {
|
||||
slot.putStack(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, button, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +73,7 @@ public class GuiCrafter extends GuiPoweredMachineBase<TileCrafter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXSize() {
|
||||
public final int getXSize() {
|
||||
return 219;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package crazypants.enderio.machine.crafter;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
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 crazypants.enderio.network.MessageTileEntity;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PacketCrafter extends MessageTileEntity<TileCrafter> implements IMessageHandler<PacketCrafter, IMessage> {
|
||||
|
||||
private int slot;
|
||||
private ItemStack stack;
|
||||
|
||||
public PacketCrafter() {
|
||||
}
|
||||
|
||||
private PacketCrafter(TileCrafter tile) {
|
||||
super(tile);
|
||||
}
|
||||
|
||||
public static PacketCrafter setSlot(TileCrafter te, int slot, ItemStack stack) {
|
||||
PacketCrafter msg = new PacketCrafter(te);
|
||||
msg.slot = slot;
|
||||
msg.stack = stack;
|
||||
msg.execute(te);
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
slot = buf.readShort();
|
||||
stack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeShort(slot);
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketCrafter msg, MessageContext ctx) {
|
||||
TileCrafter te = msg.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
|
||||
if(te != null) {
|
||||
msg.execute(te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void execute(TileCrafter te) {
|
||||
te.craftingGrid.setInventorySlotContents(slot, stack);
|
||||
te.updateCraftingOutput();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,13 @@ import crazypants.enderio.gui.ToggleButtonEIO;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
public class GuiFarmStation extends GuiPoweredMachineBase<TileFarmStation> {
|
||||
|
||||
|
||||
private static final int LOCK_ID = 1234;
|
||||
|
||||
public GuiFarmStation(InventoryPlayer par1InventoryPlayer, TileFarmStation machine) {
|
||||
super(machine, new FarmStationContainer(par1InventoryPlayer, machine));
|
||||
}
|
||||
@@ -30,25 +33,23 @@ public class GuiFarmStation extends GuiPoweredMachineBase<TileFarmStation> {
|
||||
int x = getGuiLeft() + 36;
|
||||
int y = getGuiTop() + 36;
|
||||
|
||||
buttonList.add(createButton(x, y));
|
||||
buttonList.add(createButton(x + 52, y));
|
||||
buttonList.add(createButton(x, y + 20));
|
||||
buttonList.add(createButton(x + 52, y + 20));
|
||||
id = 0;
|
||||
buttonList.add(createLockButton(TileFarmStation.minSupSlot + 0, x, y));
|
||||
buttonList.add(createLockButton(TileFarmStation.minSupSlot + 1, x + 52, y));
|
||||
buttonList.add(createLockButton(TileFarmStation.minSupSlot + 2, x, y + 20));
|
||||
buttonList.add(createLockButton(TileFarmStation.minSupSlot + 3, x + 52, y + 20));
|
||||
}
|
||||
|
||||
private int id = 0;
|
||||
private IconButtonEIO createButton(int x, int y) {
|
||||
return new ToggleButtonEIO(this, id, x, y, IconEIO.FARM_UNLOCK, IconEIO.FARM_LOCK).setSelected(getTileEntity().lockedSlots.contains(id++ + getTileEntity().minSupSlot));
|
||||
private IconButtonEIO createLockButton(int slot, int x, int y) {
|
||||
return new ToggleButtonEIO(this, LOCK_ID+slot, x, y, IconEIO.FARM_UNLOCK, IconEIO.FARM_LOCK).setSelected(getTileEntity().isSlotLocked(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawForegroundImpl(int mouseX, int mouseY) {
|
||||
super.drawForegroundImpl(mouseX, mouseY);
|
||||
|
||||
if(inventorySlots.inventorySlots.size() >= getTileEntity().maxSupSlot && !isConfigOverlayEnabled()) {
|
||||
for (int i : getTileEntity().lockedSlots) {
|
||||
if (i < inventorySlots.inventorySlots.size()) { // hack to allow old broken farms to be opened
|
||||
if(!isConfigOverlayEnabled()) {
|
||||
for(int i=TileFarmStation.minSupSlot ; i<=TileFarmStation.maxSupSlot ; i++) {
|
||||
if(getTileEntity().isSlotLocked(i)) {
|
||||
Slot slot = inventorySlots.getSlot(i);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderUtil.renderQuad2D(slot.xDisplayPosition, slot.yDisplayPosition, 0, 16, 16, new Vector4f(0, 0, 0, 0.5));
|
||||
@@ -81,8 +82,8 @@ public class GuiFarmStation extends GuiPoweredMachineBase<TileFarmStation> {
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton b) {
|
||||
if (b instanceof ToggleButtonEIO) {
|
||||
getTileEntity().toggleLockedState(b.id);
|
||||
if (b.id >= LOCK_ID+TileFarmStation.minSupSlot && b.id <= LOCK_ID+TileFarmStation.maxSupSlot) {
|
||||
getTileEntity().toggleLockedState(b.id - LOCK_ID);
|
||||
}
|
||||
super.actionPerformed(b);
|
||||
}
|
||||
@@ -92,7 +93,8 @@ public class GuiFarmStation extends GuiPoweredMachineBase<TileFarmStation> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPowerOutputLabel() {
|
||||
return "Base Use: ";
|
||||
return Lang.localize("farm.gui.baseUse");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.BitSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
@@ -10,8 +9,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -39,6 +36,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
|
||||
public enum ToolType {
|
||||
HOE {
|
||||
@Override
|
||||
boolean match(ItemStack item) {
|
||||
for (ItemStack stack : Config.farmHoes) {
|
||||
if (stack.getItem() == item.getItem()) {
|
||||
@@ -83,15 +81,13 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
private BlockCoord lastScanned;
|
||||
private EntityPlayerMP farmerJoe;
|
||||
|
||||
private int farmSize = Config.farmDefaultSize;
|
||||
private static final int minToolSlot = 0;
|
||||
private static final int maxToolSlot = 1;
|
||||
|
||||
private int minToolSlot = 0;
|
||||
private int maxToolSlot = 1;
|
||||
|
||||
int minSupSlot = maxToolSlot + 1;
|
||||
int maxSupSlot = minSupSlot + 4;
|
||||
public static final int minSupSlot = maxToolSlot + 1;
|
||||
public static final int maxSupSlot = minSupSlot + 4;
|
||||
|
||||
List<Integer> lockedSlots = new ArrayList<Integer>();
|
||||
private final BitSet lockedSlots = new BitSet();
|
||||
|
||||
private final int upgradeBonusSize = 2;
|
||||
|
||||
@@ -108,7 +104,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
public int getFarmSize() {
|
||||
return farmSize + getUpgradeDist();
|
||||
return Config.farmDefaultSize + getUpgradeDist();
|
||||
}
|
||||
|
||||
public void actionPerformed(boolean isAxe) {
|
||||
@@ -408,7 +404,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private boolean isOutputFull() {
|
||||
@@ -424,10 +419,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
public boolean hasSeed(ItemStack seeds, BlockCoord bc) {
|
||||
int slot = getSupplySlotForCoord(bc);
|
||||
ItemStack inv = inventory[slot];
|
||||
if(inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds);
|
||||
}
|
||||
|
||||
public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock) {
|
||||
@@ -555,19 +547,15 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
return new BlockCoord(nextX, lastScanned.y, nextZ);
|
||||
}
|
||||
|
||||
public void toggleLockedState(int buttonID) {
|
||||
public void toggleLockedState(int slot) {
|
||||
if (worldObj.isRemote) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFarmLockedSlot(this, buttonID));
|
||||
}
|
||||
buttonID += minSupSlot;
|
||||
if (lockedSlots.contains(buttonID)) {
|
||||
lockedSlots.remove((Integer) buttonID); // hard cast otherwise it removes by index
|
||||
} else {
|
||||
lockedSlots.add(buttonID);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFarmLockedSlot(this, slot));
|
||||
}
|
||||
lockedSlots.flip(slot);
|
||||
}
|
||||
|
||||
public boolean isSlotLocked(int slot) {
|
||||
return lockedSlots.contains(slot);
|
||||
return lockedSlots.get(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -627,11 +615,17 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.readCustomNBT(nbtRoot);
|
||||
currentTask = createTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
lockedSlots.clear();
|
||||
for (int i : nbtRoot.getIntArray("lockedSlots")) {
|
||||
lockedSlots.add(i);
|
||||
lockedSlots.set(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IPoweredTask createTask() {
|
||||
return new ContinuousTask(getPowerUsePerTick());
|
||||
}
|
||||
@@ -640,11 +634,18 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
nbtRoot.setBoolean("isActive", isActive());
|
||||
int[] locked = new int[lockedSlots.size()];
|
||||
for (int i = 0; i < lockedSlots.size(); i++) {
|
||||
locked[i] = lockedSlots.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
if(!lockedSlots.isEmpty()) {
|
||||
int[] locked = new int[lockedSlots.cardinality()];
|
||||
for (int i=0,bit=-1; (bit=lockedSlots.nextSetBit(bit+1)) >= 0; i++) {
|
||||
locked[i] = bit;
|
||||
}
|
||||
nbtRoot.setIntArray("lockedSlots", locked);
|
||||
}
|
||||
nbtRoot.setIntArray("lockedSlots", locked);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public abstract class GuiPoweredMachineBase<T extends AbstractPoweredMachineEnti
|
||||
}
|
||||
|
||||
protected void updatePowerBarTooltip(List<String> text) {
|
||||
text.add(getPowerOutputLabel() + PowerDisplayUtil.formatPower(getPowerOutputValue()) + " " + PowerDisplayUtil.abrevation()
|
||||
text.add(getPowerOutputLabel() + " " + PowerDisplayUtil.formatPower(getPowerOutputValue()) + " " + PowerDisplayUtil.abrevation()
|
||||
+ PowerDisplayUtil.perTickStr());
|
||||
text.add(PowerDisplayUtil.formatStoredPower(getTileEntity().getEnergyStored(), getTileEntity().getCapacitor().getMaxEnergyStored()));
|
||||
}
|
||||
|
||||
@@ -209,12 +209,12 @@ public class GuiVacuumChest extends GuiContainerBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putStack(ItemStack stack) {
|
||||
public void putStack(ItemStack stack) {
|
||||
PacketHandler.INSTANCE.sendToServer(PacketVaccumChest.setFilterSlot(te, slot, stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getStack() {
|
||||
public ItemStack getStack() {
|
||||
ItemFilter itemFilter = te.getItemFilter();
|
||||
if(itemFilter != null) {
|
||||
return itemFilter.getStackInSlot(slot);
|
||||
|
||||
@@ -5,6 +5,7 @@ import static crazypants.enderio.waila.IWailaInfoProvider.BIT_COMMON;
|
||||
import static crazypants.enderio.waila.IWailaInfoProvider.BIT_DETAILED;
|
||||
import static crazypants.enderio.waila.IWailaInfoProvider.fmt;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
@@ -20,7 +21,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -28,15 +28,14 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.block.BlockDarkSteelAnvil;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.liquid.AbstractTankConduit;
|
||||
import crazypants.enderio.conduit.liquid.ConduitTank;
|
||||
import crazypants.enderio.conduit.me.IMEConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.fluid.Fluids;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
@@ -46,14 +45,13 @@ import crazypants.enderio.machine.IIoConfigurable;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.capbank.TileCapBank;
|
||||
import crazypants.enderio.power.IInternalPoweredTile;
|
||||
import crazypants.enderio.power.IPowerContainer;
|
||||
import crazypants.util.IFacade;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class WailaCompat implements IWailaDataProvider {
|
||||
|
||||
private class WailaWorldWrapper extends World {
|
||||
private World wrapped;
|
||||
private final World wrapped;
|
||||
|
||||
private WailaWorldWrapper(World wrapped) {
|
||||
super(wrapped.getSaveHandler(), wrapped.getWorldInfo().getWorldName(), wrapped.provider, new WorldSettings(wrapped.getWorldInfo()), wrapped.theProfiler);
|
||||
@@ -214,52 +212,9 @@ public class WailaCompat implements IWailaDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if(te instanceof IConduitBundle && itemStack != null && itemStack.getItem() == EnderIO.itemPowerConduit) {
|
||||
NBTTagCompound nbtRoot = accessor.getNBTData();
|
||||
short nbtVersion = nbtRoot.getShort("nbtVersion");
|
||||
NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");
|
||||
if(te instanceof IConduitBundle) {
|
||||
getWailaBodyConduitBundle(itemStack, currenttip);
|
||||
|
||||
if(conduitTags != null) {
|
||||
for (int i = 0; i < conduitTags.tagCount(); i++) {
|
||||
NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
|
||||
IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
|
||||
if(conduit instanceof IPowerConduit) {
|
||||
currenttip.add(String.format("%s%s%s / %s%s%s RF", EnumChatFormatting.WHITE, fmt.format(((IPowerConduit) conduit).getEnergyStored()),
|
||||
EnumChatFormatting.RESET,
|
||||
EnumChatFormatting.WHITE, fmt.format(((IConduitBundle) te).getMaxEnergyStored()), EnumChatFormatting.RESET));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(te instanceof IConduitBundle && itemStack != null && itemStack.getItem() == EnderIO.itemLiquidConduit) {
|
||||
NBTTagCompound nbtRoot = accessor.getNBTData();
|
||||
short nbtVersion = nbtRoot.getShort("nbtVersion");
|
||||
NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");
|
||||
|
||||
if(conduitTags != null) {
|
||||
for (int i = 0; i < conduitTags.tagCount(); i++) {
|
||||
NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
|
||||
IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
|
||||
if(conduit instanceof AbstractTankConduit) {
|
||||
AbstractTankConduit tankConduit = (AbstractTankConduit) conduit;
|
||||
ConduitTank tank = tankConduit.getTank();
|
||||
if(tank.getFluid() != null) {
|
||||
String lockedStr = tankConduit.isFluidTypeLocked() ? Lang.localize("itemLiquidConduit.lockedWaila") : "";
|
||||
String fluidName = tank.getFluid().getLocalizedName();
|
||||
int fluidAmount = tank.getFluidAmount();
|
||||
if(fluidAmount > 0) {
|
||||
currenttip.add(String.format("%s%s%s%s %s%s%s %s", lockedStr,
|
||||
EnumChatFormatting.WHITE, fluidName, EnumChatFormatting.RESET,
|
||||
EnumChatFormatting.WHITE, fmt.format(fluidAmount), EnumChatFormatting.RESET,
|
||||
Fluids.MB()));
|
||||
} else if(tankConduit.isFluidTypeLocked()) {
|
||||
currenttip.add(String.format("%s%s%s%s", lockedStr,
|
||||
EnumChatFormatting.WHITE, fluidName, EnumChatFormatting.RESET));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(te instanceof IInternalPoweredTile && block == accessor.getBlock() && !(te instanceof TileCapBank)) {
|
||||
IInternalPoweredTile power = (IInternalPoweredTile) te;
|
||||
|
||||
@@ -281,6 +236,51 @@ public class WailaCompat implements IWailaDataProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
private void getWailaBodyConduitBundle(ItemStack itemStack, List<String> currenttip) {
|
||||
if(itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemStack.getItem() == EnderIO.itemPowerConduit) {
|
||||
NBTTagCompound nbtRoot = _accessor.getNBTData();
|
||||
if(nbtRoot.hasKey("storedEnergyRF")) {
|
||||
int stored = nbtRoot.getInteger("storedEnergyRF");
|
||||
int max = nbtRoot.getInteger("maxStoredRF");
|
||||
currenttip.add(String.format("%s%s%s / %s%s%s RF", EnumChatFormatting.WHITE, fmt.format(stored),
|
||||
EnumChatFormatting.RESET,
|
||||
EnumChatFormatting.WHITE, fmt.format(max), EnumChatFormatting.RESET));
|
||||
}
|
||||
|
||||
} else if(itemStack.getItem() == EnderIO.itemLiquidConduit) {
|
||||
NBTTagCompound nbtRoot = _accessor.getNBTData();
|
||||
if(nbtRoot.hasKey("fluidLocked") && nbtRoot.hasKey("FluidName")) {
|
||||
boolean fluidTypeLocked = nbtRoot.getBoolean("fluidLocked");
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbtRoot);
|
||||
String lockedStr = fluidTypeLocked ? Lang.localize("itemLiquidConduit.lockedWaila") : "";
|
||||
String fluidName = fluid.getLocalizedName();
|
||||
int fluidAmount = fluid.amount;
|
||||
if(fluidAmount > 0) {
|
||||
currenttip.add(String.format("%s%s%s%s %s%s%s %s", lockedStr,
|
||||
EnumChatFormatting.WHITE, fluidName, EnumChatFormatting.RESET,
|
||||
EnumChatFormatting.WHITE, fmt.format(fluidAmount), EnumChatFormatting.RESET,
|
||||
Fluids.MB()));
|
||||
} else if(fluidTypeLocked) {
|
||||
currenttip.add(String.format("%s%s%s%s", lockedStr,
|
||||
EnumChatFormatting.WHITE, fluidName, EnumChatFormatting.RESET));
|
||||
}
|
||||
}
|
||||
|
||||
} else if(itemStack.getItem() == EnderIO.itemMEConduit) {
|
||||
NBTTagCompound nbtRoot = _accessor.getNBTData();
|
||||
if(nbtRoot.hasKey("isDense")) {
|
||||
boolean isDense = nbtRoot.getBoolean("isDense");
|
||||
int channelsInUse = nbtRoot.getInteger("channelsInUse");
|
||||
currenttip.add(MessageFormat.format(Lang.localize("itemMEConduit.channelsUsed"),
|
||||
channelsInUse, isDense ? 32 : 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
@@ -291,12 +291,30 @@ public class WailaCompat implements IWailaDataProvider {
|
||||
if(te instanceof IWailaNBTProvider) {
|
||||
((IWailaNBTProvider) te).getData(tag);
|
||||
}
|
||||
if(te instanceof IInternalPoweredTile) {
|
||||
tag.setInteger("storedEnergyRF", ((IPowerContainer) te).getEnergyStored());
|
||||
tag.setInteger("maxStoredRF", ((IInternalPoweredTile) te).getMaxEnergyStored());
|
||||
}
|
||||
if(te instanceof IConduitBundle) {
|
||||
te.writeToNBT(tag);
|
||||
IConduitBundle icb = (IConduitBundle) te;
|
||||
IPowerConduit pc = icb.getConduit(IPowerConduit.class);
|
||||
if(pc != null) {
|
||||
tag.setInteger("storedEnergyRF", pc.getEnergyStored());
|
||||
tag.setInteger("maxStoredRF", pc.getMaxEnergyStored());
|
||||
}
|
||||
AbstractTankConduit atc = icb.getConduit(AbstractTankConduit.class);
|
||||
if(atc != null) {
|
||||
FluidStack fluid = atc.getTank().getFluid();
|
||||
if(fluid != null) {
|
||||
tag.setBoolean("fluidLocked", atc.isFluidTypeLocked());
|
||||
fluid.writeToNBT(tag);
|
||||
}
|
||||
}
|
||||
IMEConduit mec = icb.getConduit(IMEConduit.class);
|
||||
if(mec != null) {
|
||||
tag.setInteger("channelsInUse", mec.getChannelsInUse());
|
||||
tag.setBoolean("isDense", mec.isDense());
|
||||
}
|
||||
} else if(te instanceof IInternalPoweredTile) {
|
||||
IInternalPoweredTile ipte = (IInternalPoweredTile) te;
|
||||
tag.setInteger("storedEnergyRF", ipte.getEnergyStored());
|
||||
tag.setInteger("maxStoredRF", ipte.getMaxEnergyStored());
|
||||
}
|
||||
|
||||
tag.setInteger("x", x);
|
||||
|
||||
@@ -17,10 +17,10 @@ public class GhostSlot {
|
||||
return visible;
|
||||
}
|
||||
|
||||
protected ItemStack getStack() {
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected void putStack(ItemStack stack) {
|
||||
public void putStack(ItemStack stack) {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user