Rewrote vanilla inventory handling to use dedicated classes.

This commit is contained in:
SirSengir 2013-05-11 11:40:46 +02:00
parent 02c3b19ea9
commit fa38e293e5
25 changed files with 240 additions and 179 deletions

View file

@ -23,7 +23,7 @@ import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
public class GuiBlueprintLibrary extends GuiBuildCraft {
@ -67,15 +67,15 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
buttonList.add(nextPageButton);
// if (library.owner.equals(player.username)) {
deleteButton = new GuiButton(2, j + 100, k + 114, 25, 20, StringUtil.localize("gui.del"));
deleteButton = new GuiButton(2, j + 100, k + 114, 25, 20, StringUtils.localize("gui.del"));
buttonList.add(deleteButton);
lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, StringUtil.localize("gui.lock"));
lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, StringUtils.localize("gui.lock"));
buttonList.add(lockButton);
if (library.locked) {
lockButton.displayString = StringUtil.localize("gui.unlock");
lockButton.displayString = StringUtils.localize("gui.unlock");
} else {
lockButton.displayString = StringUtil.localize("gui.lock");
lockButton.displayString = StringUtils.localize("gui.lock");
}
}
@ -83,7 +83,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
// fontRenderer.drawString(library.owner + "'s Library", 6, 6,
// 0x404040);
String title = StringUtil.localize("tile.libraryBlock");
String title = StringUtils.localize("tile.libraryBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
int c = 0;
@ -127,9 +127,9 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
@Override
public void updateScreen() {
if (library.locked) {
lockButton.displayString = StringUtil.localize("gui.unlock");
lockButton.displayString = StringUtils.localize("gui.unlock");
} else {
lockButton.displayString = StringUtil.localize("gui.lock");
lockButton.displayString = StringUtils.localize("gui.lock");
}
}

View file

@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11;
import buildcraft.builders.TileBuilder;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
public class GuiBuilder extends GuiAdvancedInterface {
@ -46,13 +46,13 @@ public class GuiBuilder extends GuiAdvancedInterface {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtil.localize("tile.builderBlock");
String title = StringUtils.localize("tile.builderBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 12, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.building.resources"), 8, 60, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.building.resources"), 8, 60, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
if (builder.isBuildingBlueprint()) {
fontRenderer.drawString(StringUtil.localize("gui.needed"), 185, 7, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.needed"), 185, 7, 0x404040);
}
drawForegroundSelection(par1, par2);

View file

@ -16,7 +16,7 @@ import org.lwjgl.opengl.GL11;
import buildcraft.builders.TileFiller;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
public class GuiFiller extends GuiBuildCraft {
@ -33,10 +33,10 @@ public class GuiFiller extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtil.localize("tile.fillerBlock");
String title = StringUtils.localize("tile.fillerBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.filling.resources"), 8, 74, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, 142, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040);
if (filler.currentPattern != null) {
drawForegroundSelection(filler.currentPattern.getName());

View file

@ -22,7 +22,7 @@ import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
public class GuiTemplate extends GuiBuildCraft {
@ -41,9 +41,9 @@ public class GuiTemplate extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtil.localize("tile.architectBlock");
String title = StringUtils.localize("tile.architectBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 152, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 152, 0x404040);
if (editMode && ((new Date()).getTime() / 100) % 8 >= 4) {
fontRenderer.drawString(template.name + "|", 51, 62, 0x404040);

View file

@ -2,7 +2,7 @@ package buildcraft.core;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
public class ItemBlockBuildCraft extends ItemBlock {
@ -17,6 +17,6 @@ public class ItemBlockBuildCraft extends ItemBlock {
@Override
public String getItemDisplayName(ItemStack itemstack) {
return StringUtil.localize(getUnlocalizedName(itemstack));
return StringUtils.localize(getUnlocalizedName(itemstack));
}
}

View file

@ -12,7 +12,7 @@ package buildcraft.core;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -26,7 +26,7 @@ public class ItemBuildCraft extends Item {
@Override
public String getItemDisplayName(ItemStack itemstack) {
return StringUtil.localize(getUnlocalizedName(itemstack));
return StringUtils.localize(getUnlocalizedName(itemstack));
}
@Override

View file

@ -0,0 +1,40 @@
package buildcraft.core.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
public abstract class InventoryWrapper implements ISidedInventory {
IInventory inventory;
public InventoryWrapper(IInventory inventory) {
this.inventory = inventory;
}
/* DIRECT MAPPING */
@Override public int getSizeInventory() { return inventory.getSizeInventory(); }
@Override public ItemStack getStackInSlot(int slotIndex) { return inventory.getStackInSlot(slotIndex); }
@Override public ItemStack decrStackSize(int slotIndex, int amount) { return inventory.decrStackSize(slotIndex, amount); }
@Override public ItemStack getStackInSlotOnClosing(int slotIndex) { return inventory.getStackInSlotOnClosing(slotIndex); }
@Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { inventory.setInventorySlotContents(slotIndex, itemstack); }
@Override public String getInvName() { return inventory.getInvName(); }
@Override public boolean isInvNameLocalized() { return inventory.isInvNameLocalized(); }
@Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); }
@Override public void onInventoryChanged() { inventory.onInventoryChanged(); }
@Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inventory.isUseableByPlayer(entityplayer); }
@Override public void openChest() { inventory.openChest(); }
@Override public void closeChest() { inventory.closeChest(); }
@Override public boolean isStackValidForSlot(int slotIndex, ItemStack itemstack) { return inventory.isStackValidForSlot(slotIndex, itemstack); }
/* STATIC HELPER */
public static ISidedInventory getWrappedInventory(IInventory inventory) {
if(inventory instanceof ISidedInventory)
return (ISidedInventory)inventory;
else if(inventory instanceof net.minecraftforge.common.ISidedInventory)
return new InventoryWrapperForge((net.minecraftforge.common.ISidedInventory)inventory);
else
return new InventoryWrapperSimple(inventory);
}
}

View file

@ -0,0 +1,35 @@
package buildcraft.core.inventory;
import buildcraft.core.utils.Utils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
public class InventoryWrapperForge extends InventoryWrapper {
private int[][] sidemap;
public InventoryWrapperForge(net.minecraftforge.common.ISidedInventory inventory) {
super(inventory);
sidemap = new int[ForgeDirection.VALID_DIRECTIONS.length][];
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
sidemap[direction.ordinal()] = Utils.createSlotArray(inventory.getStartInventorySide(direction), inventory.getSizeInventorySide(direction));
}
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return sidemap[side];
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) {
return true;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return true;
}
}

View file

@ -0,0 +1,31 @@
package buildcraft.core.inventory;
import buildcraft.core.utils.Utils;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class InventoryWrapperSimple extends InventoryWrapper {
private final int[] slots;
public InventoryWrapperSimple(IInventory inventory) {
super(inventory);
slots = Utils.createSlotArray(0, inventory.getSizeInventory());
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
return slots;
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) {
return true;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return true;
}
}

View file

@ -1,6 +1,6 @@
package buildcraft.core.utils;
public class StringUtil {
public class StringUtils {
public static String localize(String key) {
return Localization.get(key);

View file

@ -14,9 +14,7 @@ import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -521,75 +519,11 @@ public class Utils {
return result;
}
public static int[] createSlotArray(int first, int last) {
int[] rv = new int[last - first + 1];
for(int k = first; k <= last; k++)
rv[k - first] = k;
return rv;
public static int[] createSlotArray(int first, int count) {
int[] slots = new int[count];
for(int k = first; k < first + count; k++)
slots[k - first] = k;
return slots;
}
public static ISidedInventory createSidedInventoryWrapper(final IInventory inv) {
if(inv instanceof ISidedInventory)
return (ISidedInventory)inv;
abstract class InventoryWrapper implements net.minecraft.inventory.ISidedInventory {
@Override public int getSizeInventory() {return inv.getSizeInventory();}
@Override public ItemStack getStackInSlot(int i) {return inv.getStackInSlot(i);}
@Override public ItemStack decrStackSize(int i, int j) {return inv.decrStackSize(i, j);}
@Override public ItemStack getStackInSlotOnClosing(int i) {return inv.getStackInSlotOnClosing(i);}
@Override public void setInventorySlotContents(int i, ItemStack itemstack) {inv.setInventorySlotContents(i, itemstack);}
@Override public String getInvName() {return inv.getInvName();}
@Override public boolean isInvNameLocalized() {return inv.isInvNameLocalized();}
@Override public int getInventoryStackLimit() {return inv.getInventoryStackLimit();}
@Override public void onInventoryChanged() {inv.onInventoryChanged();}
@Override public boolean isUseableByPlayer(EntityPlayer entityplayer) {return inv.isUseableByPlayer(entityplayer);}
@Override public void openChest() {inv.openChest();}
@Override public void closeChest() {inv.closeChest();}
@Override public boolean isStackValidForSlot(int i, ItemStack itemstack) {return inv.isStackValidForSlot(i, itemstack);}
}
if(inv instanceof net.minecraftforge.common.ISidedInventory) {
final net.minecraftforge.common.ISidedInventory sided = (net.minecraftforge.common.ISidedInventory)inv;
return new InventoryWrapper() {
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
int first = sided.getStartInventorySide(ForgeDirection.VALID_DIRECTIONS[var1]);
int size = sided.getSizeInventorySide(ForgeDirection.VALID_DIRECTIONS[var1]);
return createSlotArray(first, first + size - 1);
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return true;
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return true;
}
};
}
final int[] all_slots = createSlotArray(0, inv.getSizeInventory() - 1);
return new InventoryWrapper() {
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
return all_slots;
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return true;
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return true;
}
};
}
}

View file

@ -14,7 +14,7 @@ import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import buildcraft.BuildCraftEnergy;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -27,7 +27,7 @@ public class ItemBucketOil extends ItemBucket {
@Override
public String getItemDisplayName(ItemStack itemstack) {
return StringUtil.localize(getUnlocalizedName(itemstack));
return StringUtils.localize(getUnlocalizedName(itemstack));
}
@Override

View file

@ -18,7 +18,7 @@ import net.minecraftforge.liquids.LiquidStack;
import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.EngineIron;
import buildcraft.energy.TileEngine;
@ -31,9 +31,9 @@ public class GuiCombustionEngine extends GuiEngine {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtil.localize("tile.engineIron");
String title = StringUtils.localize("tile.engineIron");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
@Override

View file

@ -6,7 +6,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.core.CoreIconProvider;
import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.Engine;
import buildcraft.energy.TileEngine;
@ -38,12 +38,12 @@ public abstract class GuiEngine extends GuiBuildCraft {
if (!isFullyOpened())
return;
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawString(engine.getCurrentOutput() + " MJ/t", x + 22, y + 32, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawString(engine.getEnergyStored() + " MJ", x + 22, y + 56, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawString(((double) engine.getHeat() / (double) 100 + 20.0) + " \u00B0C", x + 22, y + 80, textColour);
}

View file

@ -14,7 +14,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngine;
public class GuiSteamEngine extends GuiEngine {
@ -26,9 +26,9 @@ public class GuiSteamEngine extends GuiEngine {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtil.localize("tile.engineStone");
String title = StringUtils.localize("tile.engineStone");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
@Override

View file

@ -15,7 +15,7 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.factory.TileAutoWorkbench;
public class GuiAutoCrafting extends GuiBuildCraft {
@ -34,9 +34,9 @@ public class GuiAutoCrafting extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtil.localize("tile.autoWorkbenchBlock");
String title = StringUtils.localize("tile.autoWorkbenchBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
@Override

View file

@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11;
import buildcraft.api.recipes.RefineryRecipe;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.factory.TileRefinery;
public class GuiRefinery extends GuiAdvancedInterface {
@ -43,11 +43,11 @@ public class GuiRefinery extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtil.localize("tile.refineryBlock");
String title = StringUtils.localize("tile.refineryBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString("->", 63, 59, 0x404040);
fontRenderer.drawString("<-", 106, 59, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -12,7 +12,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.core.CoreIconProvider;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.silicon.TileAssemblyAdvancedWorkbench;
public class GuiAssemblyAdvancedWorkbench extends GuiAdvancedInterface {
@ -39,12 +39,12 @@ public class GuiAssemblyAdvancedWorkbench extends GuiAdvancedInterface {
if (!isFullyOpened())
return;
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", workbench.getRequiredEnergy()), x + 22, y + 32, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", workbench.getStoredEnergy()), x + 22, y + 56, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawString(String.format("%3.2f MJ/t", workbench.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour);
}
@ -93,9 +93,9 @@ public class GuiAssemblyAdvancedWorkbench extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtil.localize("tile.assemblyWorkbenchBlock");
String title = StringUtils.localize("tile.assemblyWorkbenchBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -28,7 +28,7 @@ import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.silicon.TileAssemblyTable;
import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
@ -59,12 +59,12 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
if (!isFullyOpened())
return;
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", assemblyTable.getRequiredEnergy()), x + 22, y + 32, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", assemblyTable.getStoredEnergy()), x + 22, y + 56, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawString(String.format("%3.2f MJ/t", assemblyTable.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour);
}
@ -135,9 +135,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtil.localize("tile.assemblyTableBlock");
String title = StringUtils.localize("tile.assemblyTableBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 15, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -15,7 +15,7 @@ import buildcraft.api.transport.IPipe;
import buildcraft.core.DefaultProps;
import buildcraft.core.GuiIds;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.core.utils.Utils;
import buildcraft.transport.pipes.PipePowerWood;
import buildcraft.transport.triggers.ActionEnergyPulser;
@ -87,19 +87,19 @@ public class GateVanilla extends Gate {
public String getName() {
switch (kind) {
case Single:
return StringUtil.localize("item.pipeGate.0");
return StringUtils.localize("item.pipeGate.0");
case AND_2:
return StringUtil.localize("item.pipeGate.1");
return StringUtils.localize("item.pipeGate.1");
case AND_3:
return StringUtil.localize("item.pipeGate.3");
return StringUtils.localize("item.pipeGate.3");
case AND_4:
return StringUtil.localize("item.pipeGate.5");
return StringUtils.localize("item.pipeGate.5");
case OR_2:
return StringUtil.localize("item.pipeGate.2");
return StringUtils.localize("item.pipeGate.2");
case OR_3:
return StringUtil.localize("item.pipeGate.4");
return StringUtils.localize("item.pipeGate.4");
case OR_4:
return StringUtil.localize("item.pipeGate.6");
return StringUtils.localize("item.pipeGate.6");
default:
return "";
}

View file

@ -19,7 +19,7 @@ import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketSlotChange;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.pipes.PipeLogicDiamond;
@ -48,7 +48,7 @@ public class GuiDiamondPipe extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -19,7 +19,7 @@ import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketSlotChange;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.pipes.PipeItemsEmerald;
@ -45,7 +45,7 @@ public class GuiEmeraldPipe extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 93, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -21,7 +21,7 @@ import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.utils.StringUtil;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.Gate.GateKind;
import buildcraft.transport.Pipe;
import cpw.mods.fml.relauncher.Side;
@ -228,7 +228,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
String name = _container.getGateName();
fontRenderer.drawString(name, getCenteredOffset(name), 15, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
}

View file

@ -20,7 +20,6 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import buildcraft.BuildCraftTransport;
import buildcraft.api.inventory.ISelectiveInventory;
import buildcraft.api.inventory.ISpecialInventory;
@ -76,7 +75,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
@Override
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
// ISELECTIVEINVENTORY
/* ISELECTIVEINVENTORY */
if (inventory instanceof ISelectiveInventory) {
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) getPowerProvider().getEnergyStored());
if (doRemove) {
@ -88,41 +87,53 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
incrementFilter();
}
return stacks;
}
// ISPECIALINVENTORY
if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) getPowerProvider().getEnergyStored());
if (stacks != null) {
for (ItemStack stack : stacks) {
if(stack == null)
continue;
boolean matches = false;
for (int i = 0; i < filters.getSizeInventory(); i++) {
ItemStack filter = filters.getStackInSlot(i);
if (filter != null && filter.isItemEqual(stack)) {
matches = true;
break;
}
}
if (!matches) {
return null;
}
}
if (doRemove) {
stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) getPowerProvider().getEnergyStored());
/* ISPECIALINVENTORY */
} else if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) getPowerProvider().getEnergyStored());
if (stacks != null) {
for (ItemStack stack : stacks) {
if (stack != null) {
getPowerProvider().useEnergy(stack.stackSize, stack.stackSize, true);
if(stack == null)
continue;
boolean matches = false;
for (int i = 0; i < filters.getSizeInventory(); i++) {
ItemStack filter = filters.getStackInSlot(i);
if (filter != null && filter.isItemEqual(stack)) {
matches = true;
break;
}
}
if (!matches) {
return null;
}
}
if (doRemove) {
stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) getPowerProvider().getEnergyStored());
for (ItemStack stack : stacks) {
if (stack != null) {
getPowerProvider().useEnergy(stack.stackSize, stack.stackSize, true);
}
}
}
}
return stacks;
} else {
// This is a generic inventory
IInventory inv = Utils.getInventory(inventory);
ItemStack result = checkExtractGeneric(inv, doRemove, from, 0, inv.getSizeInventory() - 1);
if (result != null) {
return new ItemStack[]{result};
}
return stacks;
}
return null;
/*
if (inventory instanceof ISidedInventory) {
ISidedInventory sidedInv = (ISidedInventory) inventory;
@ -147,7 +158,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
}
}
return null;
return null; */
}
private void incrementFilter() {

View file

@ -25,6 +25,7 @@ import buildcraft.api.transport.IPipedItem;
import buildcraft.api.transport.PipeManager;
import buildcraft.core.EntityPassiveItem;
import buildcraft.core.RedstonePowerFramework;
import buildcraft.core.inventory.InventoryWrapper;
import buildcraft.core.utils.Utils;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
@ -134,7 +135,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
*/
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
// / ISPECIALINVENTORY
/* ISPECIALINVENTORY */
if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, (int) powerProvider.getEnergyStored());
if (stacks != null && doRemove) {
@ -145,8 +146,18 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
}
}
return stacks;
} else {
IInventory inv = Utils.getInventory(inventory);
ItemStack result = checkExtractGeneric(inv, doRemove, from, 0, inv.getSizeInventory() - 1);
if (result != null)
return new ItemStack[] { result };
}
return null;
/*
if (inventory instanceof ISidedInventory) {
net.minecraft.inventory.ISidedInventory sidedInv = (ISidedInventory) inventory;
@ -156,7 +167,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
if (result != null)
return new ItemStack[] { result };
} else if (inventory instanceof net.minecraftforge.common.ISidedInventory) {
net.minecraftforge.common.ISidedInventory sidedInv = (net.minecraftforge.common.ISidedInventory) inventory;
@ -219,12 +230,11 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
if (result != null)
return new ItemStack[] { result };
}
return null;
*/
}
public ItemStack checkExtractGeneric(IInventory inventory, boolean doRemove, ForgeDirection from, int start, int stop) {
return checkExtractGeneric(Utils.createSidedInventoryWrapper(inventory), doRemove, from, Utils.createSlotArray(start, stop));
return checkExtractGeneric(InventoryWrapper.getWrappedInventory(inventory), doRemove, from, Utils.createSlotArray(start, stop - start));
}
public ItemStack checkExtractGeneric(ISidedInventory inventory, boolean doRemove, ForgeDirection from, int[] slots) {