From 4e0279dd643692d6532bac598451b99b601c5285 Mon Sep 17 00:00:00 2001 From: mozipi Date: Sun, 16 Dec 2012 08:06:45 +0900 Subject: [PATCH] =?utf8?q?GUI=E3=81=AESlot=E8=BF=BD=E5=8A=A0=20=E7=94=BB?= =?utf8?q?=E5=83=8F=E3=83=91=E3=82=B9=E3=82=92=E5=A4=89=E6=95=B0=E5=8C=96?= =?utf8?q?=20=E3=83=95=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E5=A4=89?= =?utf8?q?=E6=95=B0=E3=82=92static=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=B9?= =?utf8?q?=E3=81=8F=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F=20ClientProxy.java=E3=81=ABpreloadTexture?= =?utf8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- common/chemicraft/Auxiliary.java | 2 +- common/chemicraft/BlockChemicalCraftingTable.java | 19 ++++++ common/chemicraft/ChemiCraft.java | 78 +++++++++++++--------- common/chemicraft/CommonProxy.java | 4 ++ .../chemicraft/ContainerChemicalCraftingTable.java | 8 ++- common/chemicraft/CreativeTabAtoms.java | 2 +- common/chemicraft/GuiChemicalCraftingTable.java | 11 ++- common/chemicraft/ItemAtoms.java | 6 +- common/chemicraft/ItemCompounds.java | 2 +- common/chemicraft/PacketHandler.java | 2 +- common/chemicraft/SlotDecompositionResult.java | 19 ++++++ .../TileEntityChemicalCraftingTable.java | 9 +-- src/chemicraft/client/ClientProxy.java | 9 +++ 13 files changed, 119 insertions(+), 52 deletions(-) create mode 100644 common/chemicraft/SlotDecompositionResult.java diff --git a/common/chemicraft/Auxiliary.java b/common/chemicraft/Auxiliary.java index 5444115..f62fbef 100644 --- a/common/chemicraft/Auxiliary.java +++ b/common/chemicraft/Auxiliary.java @@ -1,4 +1,4 @@ -package landminecraft; +package chemicraft; import net.minecraft.src.Block; import net.minecraft.src.Item; diff --git a/common/chemicraft/BlockChemicalCraftingTable.java b/common/chemicraft/BlockChemicalCraftingTable.java index 6fb31d7..f2b9793 100644 --- a/common/chemicraft/BlockChemicalCraftingTable.java +++ b/common/chemicraft/BlockChemicalCraftingTable.java @@ -25,6 +25,25 @@ public class BlockChemicalCraftingTable extends BlockContainer { @Override + public String getTextureFile(){ + return ChemiCraft.instance.blockChemicalCraftingTableTexture; + } + + + + @Override + public int getBlockTextureFromSide(int par1) + { + if(par1 == 0){ + return 0; + }else{ + return 1; + } + } + + + + @Override public TileEntity createNewTileEntity(World var1){ return new TileEntityChemicalCraftingTable(); } diff --git a/common/chemicraft/ChemiCraft.java b/common/chemicraft/ChemiCraft.java index 67993ad..ff5f577 100644 --- a/common/chemicraft/ChemiCraft.java +++ b/common/chemicraft/ChemiCraft.java @@ -26,7 +26,7 @@ import cpw.mods.fml.common.registry.GameRegistry; // クライアント、サーバー共に必要 1.3.2用 public class ChemiCraft { - public static final String[] atomsName = { + public final String[] atomsName = { "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", @@ -40,7 +40,7 @@ public class ChemiCraft { }; - public static final String[] atomsNameJP = { + public final String[] atomsNameJP = { "水素", "ヘリウム", "リチウム", "ベリウム", "ホウ素", "炭素", "窒素", "酸素", "フッ素", "ネオン", "ナトリウム", "マグネシウム", "アルミニウム", "ケイ素", "リン", "硫黄", "塩素", "アルゴン", "カリウム", "カルシウム", "スカンジウム", "チタン", "バナジウム", "クロム", "マンガン", "鉄", "コバルト", "ニッケル", "銅", "亜鉛", "ガリウム", "ゲルマニウム", "ヒ素", "セレン", "臭素", "クリプトン", "ルビジウム", "ストロンチウム", "イットリウム", "ジルコニウム", "ニオブ", "モリブデン", "テクネチウム", "ルテニウム", "ロジウム", "パラジウム", "銀", "カドミウム", "インジウム", "スズ", "アンチモン", "テルル", @@ -69,48 +69,61 @@ public class ChemiCraft { /** * ChemiCraftのCreativeTab */ - public static CreativeTabs creativeTab = new CreativeTabAtoms("ChemiCraft"); + public CreativeTabs creativeTab = new CreativeTabAtoms("ChemiCraft"); /** * ItemID */ - public static int atomsID; - public static int compoundsID; - public static int gasCollectingBottleID; + public int atomsID; + public int compoundsID; + public int gasCollectingBottleID; /** * BlockID */ - public static int chemicalCraftingTableID; + public int chemicalCraftingTableID; /** * GUIID */ - public static int guiChemicalCraftingTableID; + public int guiChemicalCraftingTableID; /** * Block型変数 */ - public static Block blockChemicalCraftingTable; + public Block blockChemicalCraftingTable; /** * Item型変数 */ - public static Item itemAtoms; - public static Item itemCompounds; - public static Item itemGasCollectingBottle; + public Item itemAtoms; + public Item itemCompounds; + public Item itemGasCollectingBottle; + + + /** + * このmodで使用するTextureのパス + */ + private String resourcePath = "/resource/chemiCraft"; + public String itemAtomsTexture = resourcePath + "/items/Atoms.png"; + public String itemCompoundsTexture = resourcePath + "/items/Compounds.png"; + public String blockChemicalCraftingTableTexture = resourcePath + "/blocks/CCTable.png"; + public String guiDecompositionTexture = resourcePath + "/guis/Decomposition.png"; + public String guiChemicalCombinationTexture = resourcePath + "/guis/ChemicalCombination.png"; + public String guiToolAndWeaponCraftingTexture = resourcePath + "/guis/ToolAndWeaponCrafting.png"; + public String guiMaterialCraftingTexture = resourcePath + "/guis/MaterialCrafting.png"; /** * このmodに必要な補助クラスのインスタンス */ - private static Auxiliary Auxiliary = new Auxiliary(); - private static NameAuxiliary NameAuxiliary = Auxiliary.new NameAuxiliary(); + private Auxiliary Auxiliary = new Auxiliary(); + private NameAuxiliary NameAuxiliary = Auxiliary.new NameAuxiliary(); @@ -125,11 +138,11 @@ public class ChemiCraft { Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002); Property guiChemicalCraftingTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1000); - chemicalCraftingTableID = chemicalCraftingTableIDProp.getInt(); - atomsID = atomsIDProp.getInt(); - compoundsID = compoundsIDProp.getInt(); - gasCollectingBottleID = gasCollectingBottleIDProp.getInt(); - guiChemicalCraftingTableID = guiChemicalCraftingTableIDProp.getInt(); + this.chemicalCraftingTableID = chemicalCraftingTableIDProp.getInt(); + this.atomsID = atomsIDProp.getInt(); + this.compoundsID = compoundsIDProp.getInt(); + this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt(); + this.guiChemicalCraftingTableID = guiChemicalCraftingTableIDProp.getInt(); cfg.save(); } @@ -139,30 +152,30 @@ public class ChemiCraft { @Mod.PostInit public void chemiPostLoadMethod(FMLPostInitializationEvent event){ // API用の処理 - NameAuxiliary.addName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray()); - NameAuxiliary.addName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray()); + this.NameAuxiliary.addName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray()); + this.NameAuxiliary.addName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray()); // Blockを追加します - blockChemicalCraftingTable = new BlockChemicalCraftingTable(chemicalCraftingTableID, Block.workbench.blockIndexInTexture, Material.ground) + this.blockChemicalCraftingTable = new BlockChemicalCraftingTable(chemicalCraftingTableID, 0, Material.ground) .setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundStoneFootstep).setBlockName("ChemicalCraftingTable"); // Itemを追加します - itemAtoms = new ItemAtoms(atomsID).setItemName("atoms"); - itemCompounds = new ItemCompounds(compoundsID).setItemName("compounds"); - itemGasCollectingBottle = new ItemGasCollectingBottle(gasCollectingBottleID).setItemName("gasCollectingBottle"); + this.itemAtoms = new ItemAtoms(atomsID).setItemName("atoms"); + this.itemCompounds = new ItemCompounds(compoundsID).setItemName("compounds"); + this.itemGasCollectingBottle = new ItemGasCollectingBottle(gasCollectingBottleID).setItemName("gasCollectingBottle"); // BlockをMinecraftに登録します GameRegistry.registerBlock(blockChemicalCraftingTable); // Blockの名前を設定します - NameAuxiliary.addName(blockChemicalCraftingTable, "ChemicalCraftingTable"); - NameAuxiliary.addName(blockChemicalCraftingTable, "ja_JP", "科学作業台"); + this.NameAuxiliary.addName(blockChemicalCraftingTable, "ChemicalCraftingTable"); + this.NameAuxiliary.addName(blockChemicalCraftingTable, "ja_JP", "科学作業台"); // Itemの名前を設定します - NameAuxiliary.addName(itemAtoms, atomsName); - NameAuxiliary.addName(itemAtoms, "ja_JP", atomsNameJP); - NameAuxiliary.addName(itemGasCollectingBottle, "GasCollectingBottle"); - NameAuxiliary.addName(itemGasCollectingBottle, "ja_JP", "集気瓶"); + this.NameAuxiliary.addName(itemAtoms, atomsName); + this.NameAuxiliary.addName(itemAtoms, "ja_JP", atomsNameJP); + this.NameAuxiliary.addName(itemGasCollectingBottle, "GasCollectingBottle"); + this.NameAuxiliary.addName(itemGasCollectingBottle, "ja_JP", "集気瓶"); // 化合物の名前を設定し追加します ChemiCraftAPI.addLangCompound("ja_JP", "Salt", "塩"); @@ -173,6 +186,9 @@ public class ChemiCraft { // GUIを追加します NetworkRegistry.instance().registerGuiHandler(instance, proxy); + //画像をpreloadします + this.proxy.registerTextures(); + } } \ No newline at end of file diff --git a/common/chemicraft/CommonProxy.java b/common/chemicraft/CommonProxy.java index fd85bef..3abbf2c 100644 --- a/common/chemicraft/CommonProxy.java +++ b/common/chemicraft/CommonProxy.java @@ -8,6 +8,10 @@ import cpw.mods.fml.common.network.IGuiHandler; public class CommonProxy implements IGuiHandler { + public void registerTextures(){ + + } + public void registerRenderInformation() { } diff --git a/common/chemicraft/ContainerChemicalCraftingTable.java b/common/chemicraft/ContainerChemicalCraftingTable.java index f034a64..b7f689c 100644 --- a/common/chemicraft/ContainerChemicalCraftingTable.java +++ b/common/chemicraft/ContainerChemicalCraftingTable.java @@ -88,16 +88,18 @@ public class ContainerChemicalCraftingTable extends Container { - private void generateSlots(String activeTabs, IInventory inventory){ + private void generateSlots(String activeTabs, IInventory[] inventorys){ if(activeTabs.equals("Decomposition")){ int count = 0; for(int i = 0;i < 4;i++){ for(int j = 0;j < 4;j++){ - this.addSlotToContainer(new Slot(inventory, count, 90 + 18 * j, 8 + 18 * i)); + this.addSlotToContainer(new SlotDecompositionResult(inventorys[0], count, 90 + 18 * j, 8 + 18 * i)); count++; } } - this.addSlotToContainer(new Slot(inventory, count, 25 + 4, 26 + 4)); + this.addSlotToContainer(new Slot(inventorys[0], count, 25 + 4, 26 + 4)); + }else if(activeTabs.equals("ChemicalCombination")){ + }else{ return; } diff --git a/common/chemicraft/CreativeTabAtoms.java b/common/chemicraft/CreativeTabAtoms.java index dbc28e4..0d7f224 100644 --- a/common/chemicraft/CreativeTabAtoms.java +++ b/common/chemicraft/CreativeTabAtoms.java @@ -14,7 +14,7 @@ public class CreativeTabAtoms extends CreativeTabs { @Override @SideOnly(Side.CLIENT) public int getTabIconItemIndex(){ - return ChemiCraft.itemGasCollectingBottle.shiftedIndex; + return ChemiCraft.instance.itemGasCollectingBottle.shiftedIndex; } diff --git a/common/chemicraft/GuiChemicalCraftingTable.java b/common/chemicraft/GuiChemicalCraftingTable.java index 2a5524c..8f79816 100644 --- a/common/chemicraft/GuiChemicalCraftingTable.java +++ b/common/chemicraft/GuiChemicalCraftingTable.java @@ -8,6 +8,7 @@ import net.minecraft.src.EntityPlayer; import net.minecraft.src.GuiContainer; import net.minecraft.src.InventoryBasic; import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; @@ -18,12 +19,6 @@ import cpw.mods.fml.common.network.Player; public class GuiChemicalCraftingTable extends GuiContainer { /** - * 分解機GUIのInventoryBasicクラス - */ - private static InventoryBasic decompositionSlots = new InventoryBasic("Decomposition", 17); - - - /** * TabListのArrayList */ private ArrayList tabList = new ArrayList(); @@ -70,7 +65,9 @@ public class GuiChemicalCraftingTable extends GuiContainer { this.container = (ContainerChemicalCraftingTable) this.inventorySlots; //TabListにTabを追加する this.addTabs(0, "Decomposition", new ItemStack(Block.tnt.blockID, 1, 1)); - this.addTabs(1, "Test", new ItemStack(Block.bedrock.blockID, 1, 1)); + this.addTabs(1, "ChemicalCombination", new ItemStack(ChemiCraft.instance.itemAtoms, 1, 0)); + this.addTabs(2, "ToolAndWeaponCrafting", new ItemStack(Item.pickaxeSteel, 1, 0)); + this.addTabs(3, "MaterialCrafting", new ItemStack(Item.fireballCharge, 1, 0)); //ActiveTabの初期化 for(int i = 0;i < tabList.size();i++){ String field_00001 = this.tabList.get(i).getTabName(); diff --git a/common/chemicraft/ItemAtoms.java b/common/chemicraft/ItemAtoms.java index c5d5293..b0f6ffa 100644 --- a/common/chemicraft/ItemAtoms.java +++ b/common/chemicraft/ItemAtoms.java @@ -26,7 +26,7 @@ public class ItemAtoms extends Item { @SideOnly(Side.CLIENT) @Override public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){ - for(int type = 0; type < ChemiCraft.atomsName.length; type++) + for(int type = 0; type < ChemiCraft.instance.atomsName.length; type++) { par3List.add(new ItemStack(par1, 1, type)); this.setIconIndex(type); @@ -37,14 +37,14 @@ public class ItemAtoms extends Item { @Override public String getItemNameIS(ItemStack par1ItemStack){ - return super.getItemName() + "." + ChemiCraft.atomsName[par1ItemStack.getItemDamage()]; + return super.getItemName() + "." + ChemiCraft.instance.atomsName[par1ItemStack.getItemDamage()]; } @Override public String getTextureFile(){ - return "/resource/chemicraft/items/Atoms.png"; + return ChemiCraft.instance.itemAtomsTexture; } diff --git a/common/chemicraft/ItemCompounds.java b/common/chemicraft/ItemCompounds.java index aac036a..a969f55 100644 --- a/common/chemicraft/ItemCompounds.java +++ b/common/chemicraft/ItemCompounds.java @@ -56,7 +56,7 @@ public class ItemCompounds extends Item { @Override public String getTextureFile(){ - return "/resource/chemicraft/items/Compounds.png"; + return ChemiCraft.instance.itemCompoundsTexture; } diff --git a/common/chemicraft/PacketHandler.java b/common/chemicraft/PacketHandler.java index d5d530a..cb1efed 100644 --- a/common/chemicraft/PacketHandler.java +++ b/common/chemicraft/PacketHandler.java @@ -43,7 +43,7 @@ public class PacketHandler implements IPacketHandler { y = var1.readInt(); z = var1.readInt(); - worldClient = ChemiCraft.proxy.getClientWorld(); + worldClient = ChemiCraft.instance.proxy.getClientWorld(); worldServer = ((EntityPlayer)player).worldObj; if(worldClient != null){ tileEntity = worldClient.getBlockTileEntity(x, y, z); diff --git a/common/chemicraft/SlotDecompositionResult.java b/common/chemicraft/SlotDecompositionResult.java new file mode 100644 index 0000000..071bc56 --- /dev/null +++ b/common/chemicraft/SlotDecompositionResult.java @@ -0,0 +1,19 @@ +package chemicraft; + +import net.minecraft.src.IInventory; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; + +public class SlotDecompositionResult extends Slot { + + public SlotDecompositionResult(IInventory par1iInventory, int par2, int par3, int par4) { + super(par1iInventory, par2, par3, par4); + } + + @Override + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + +} diff --git a/common/chemicraft/TileEntityChemicalCraftingTable.java b/common/chemicraft/TileEntityChemicalCraftingTable.java index a2a1c30..cf8fa02 100644 --- a/common/chemicraft/TileEntityChemicalCraftingTable.java +++ b/common/chemicraft/TileEntityChemicalCraftingTable.java @@ -1,6 +1,7 @@ package chemicraft; import java.io.DataOutputStream; +import java.util.ArrayList; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; @@ -8,8 +9,6 @@ import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagList; import net.minecraft.src.Packet; import net.minecraft.src.TileEntity; -import net.minecraft.src.WorldClient; -import net.minecraft.src.WorldServer; import com.google.common.io.ByteArrayDataInput; @@ -93,9 +92,11 @@ public class TileEntityChemicalCraftingTable extends TileEntity { } - public IInventory getActiveInventory(){ + public IInventory[] getActiveInventory(){ + ArrayList inventorys = new ArrayList(); if(this.activeTab.equals("Decomposition")){ - return this.decompositionInv; + inventorys.add(this.decompositionInv); + return inventorys.toArray(new IInventory[1]); }else{ return null; } diff --git a/src/chemicraft/client/ClientProxy.java b/src/chemicraft/client/ClientProxy.java index 2266d51..cd48026 100644 --- a/src/chemicraft/client/ClientProxy.java +++ b/src/chemicraft/client/ClientProxy.java @@ -3,6 +3,8 @@ package chemicraft.client; import net.minecraft.src.EntityPlayer; import net.minecraft.src.TileEntity; import net.minecraft.src.World; +import net.minecraftforge.client.MinecraftForgeClient; +import chemicraft.ChemiCraft; import chemicraft.CommonProxy; import chemicraft.GuiChemicalCraftingTable; import chemicraft.TileEntityChemicalCraftingTable; @@ -11,6 +13,13 @@ import cpw.mods.fml.client.FMLClientHandler; public class ClientProxy extends CommonProxy { @Override + public void registerTextures(){ + MinecraftForgeClient.preloadTexture(ChemiCraft.instance.blockChemicalCraftingTableTexture); + MinecraftForgeClient.preloadTexture(ChemiCraft.instance.itemAtomsTexture); + MinecraftForgeClient.preloadTexture(ChemiCraft.instance.itemCompoundsTexture); + } + + @Override public void registerRenderInformation() { } -- 2.11.0