From 81886bc8d753936aeb029758cdb9f2a97b565d38 Mon Sep 17 00:00:00 2001 From: Adam Rosadzinski Date: Tue, 16 Jul 2013 15:40:35 +0200 Subject: [PATCH] Clean up inventory code, chat message changes Remove support for non-existing ISidedInventory from Forge Fixed sending chat message to player - 1.6 changes --- common/buildcraft/core/CommandBuildCraft.java | 13 +++---- .../core/TickHandlerCoreClient.java | 6 ++-- .../core/inventory/InventoryIterator.java | 4 +-- .../core/inventory/InventoryWrapper.java | 2 -- .../core/inventory/InventoryWrapperForge.java | 35 ------------------- .../buildcraft/core/inventory/Transactor.java | 2 -- 6 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 common/buildcraft/core/inventory/InventoryWrapperForge.java diff --git a/common/buildcraft/core/CommandBuildCraft.java b/common/buildcraft/core/CommandBuildCraft.java index b9567c03..f55b391f 100644 --- a/common/buildcraft/core/CommandBuildCraft.java +++ b/common/buildcraft/core/CommandBuildCraft.java @@ -6,6 +6,7 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; +import net.minecraft.util.ChatMessageComponent; public class CommandBuildCraft extends CommandBase { @@ -45,9 +46,9 @@ public class CommandBuildCraft extends CommandBase { commandVersion(sender, arguments); return; } else if (arguments[0].matches("help")) { - sender.sendChatToPlayer("Format: '" + this.getCommandName() + " '"); - sender.sendChatToPlayer("Available commands:"); - sender.sendChatToPlayer("- version : Version information."); + sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Format: '" + this.getCommandName() + " '")); + sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Available commands:")); + sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("- version : Version information.")); return; } @@ -57,11 +58,11 @@ public class CommandBuildCraft extends CommandBase { private void commandVersion(ICommandSender sender, String[] arguments) { String colour = Version.isOutdated() ? "\u00A7c" : "\u00A7a"; - sender.sendChatToPlayer(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), - CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion())); + sender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), + CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion()))); if (Version.isOutdated()) { for (String updateLine : Version.getChangelog()) { - sender.sendChatToPlayer("\u00A79" + updateLine); + sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("\u00A79" + updateLine)); } } } diff --git a/common/buildcraft/core/TickHandlerCoreClient.java b/common/buildcraft/core/TickHandlerCoreClient.java index bd99976c..30dfc977 100644 --- a/common/buildcraft/core/TickHandlerCoreClient.java +++ b/common/buildcraft/core/TickHandlerCoreClient.java @@ -25,12 +25,12 @@ public class TickHandlerCoreClient implements ITickHandler { // if(!Config.disableVersionCheck) { if (Version.needsUpdateNoticeAndMarkAsSeen()) { - player.sendChatToPlayer(String.format("\u00A7cNew version of BuildCraft available: %s for Minecraft %s", Version.getRecommendedVersion(), + player.addChatMessage(String.format("\u00A7cNew version of BuildCraft available: %s for Minecraft %s", Version.getRecommendedVersion(), CoreProxy.proxy.getMinecraftVersion())); for (String updateLine : Version.getChangelog()) { - player.sendChatToPlayer("\u00A79" + updateLine); + player.addChatMessage("\u00A79" + updateLine); } - player.sendChatToPlayer("\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again."); + player.addChatMessage("\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again."); } // } diff --git a/common/buildcraft/core/inventory/InventoryIterator.java b/common/buildcraft/core/inventory/InventoryIterator.java index 124a682e..62c63d0a 100644 --- a/common/buildcraft/core/inventory/InventoryIterator.java +++ b/common/buildcraft/core/inventory/InventoryIterator.java @@ -21,9 +21,7 @@ public class InventoryIterator { if (inv instanceof ISidedInventory) { return new InventoryIteratorSided((ISidedInventory) inv, side); } - if (inv instanceof net.minecraftforge.common.ISidedInventory) { - return new InventoryIteratorSided(InventoryWrapper.getWrappedInventory(inv), side); - } + return new InventoryIteratorSimple(inv); } diff --git a/common/buildcraft/core/inventory/InventoryWrapper.java b/common/buildcraft/core/inventory/InventoryWrapper.java index 38b5d479..da5f8e34 100644 --- a/common/buildcraft/core/inventory/InventoryWrapper.java +++ b/common/buildcraft/core/inventory/InventoryWrapper.java @@ -33,8 +33,6 @@ public abstract class InventoryWrapper implements ISidedInventory { public static ISidedInventory getWrappedInventory(Object 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 if(inventory instanceof IInventory) return new InventoryWrapperSimple(Utils.getInventory((IInventory)inventory)); else diff --git a/common/buildcraft/core/inventory/InventoryWrapperForge.java b/common/buildcraft/core/inventory/InventoryWrapperForge.java deleted file mode 100644 index 91f2ba8c..00000000 --- a/common/buildcraft/core/inventory/InventoryWrapperForge.java +++ /dev/null @@ -1,35 +0,0 @@ -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; - } - -} diff --git a/common/buildcraft/core/inventory/Transactor.java b/common/buildcraft/core/inventory/Transactor.java index fd2df49e..d1e5f40d 100644 --- a/common/buildcraft/core/inventory/Transactor.java +++ b/common/buildcraft/core/inventory/Transactor.java @@ -24,8 +24,6 @@ public abstract class Transactor implements ITransactor { return new TransactorSpecial((ISpecialInventory) object); else if (object instanceof ISidedInventory) return new TransactorSimple((ISidedInventory) object); - else if (object instanceof net.minecraftforge.common.ISidedInventory) - return new TransactorSimple(InventoryWrapper.getWrappedInventory(object)); else if (object instanceof IInventory) return new TransactorSimple(Utils.getInventory((IInventory) object));