This commit is contained in:
mDiyo 2013-01-20 01:14:32 -08:00
parent 8e3684ae99
commit 7407d5af58
36 changed files with 915 additions and 157 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,12 +1,5 @@
package tinker.common; package tinker.common;
import inficraft.api.machines.BlockLogicBase;
import inficraft.infiblocks.tech.FurnaceLogic;
import java.util.Random;
import tinker.tconstruct.TConstruct;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
@ -18,6 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.tconstruct.TConstruct;
public abstract class InventoryBlock extends BlockContainer public abstract class InventoryBlock extends BlockContainer
{ {

View File

@ -60,7 +60,6 @@ public class AbilityHelper
{ {
int damage = tags.getCompoundTag("InfiTool").getInteger("Damage"); int damage = tags.getCompoundTag("InfiTool").getInteger("Damage");
int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
if ((damage + dam) > maxDamage) if ((damage + dam) > maxDamage)
{ {
breakTool(stack, tags, entity); breakTool(stack, tags, entity);
@ -238,7 +237,8 @@ public class AbilityHelper
else else
mob.attackEntityFrom(DamageSource.causeMobDamage(player), attack); mob.attackEntityFrom(DamageSource.causeMobDamage(player), attack);
} }
if (mob.hurtResistantTime <= 0) System.out.println("Hit entity");
//if (mob.hurtResistantTime <= 0)
damageTool(stack, 1, tags, player); damageTool(stack, 1, tags, player);
} }

View File

@ -14,9 +14,9 @@ public class PHConstruct {
* Second: Create the actual config file * Second: Create the actual config file
* Note: Configs are a pain, but absolutely necessary for every mod. * Note: Configs are a pain, but absolutely necessary for every mod.
*/ */
File file = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop"); File file = new File(TConstruct.proxy.getLocation() + "/config");
file.mkdir(); file.mkdir();
File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop/TConstruct.txt"); File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop.txt");
/* Some basic debugging will go a long way */ /* Some basic debugging will go a long way */
try try
@ -69,7 +69,7 @@ public class PHConstruct {
frypanHead = config.getItem("Tool Parts", "Frypan Head", 14035).getInt(14035); frypanHead = config.getItem("Tool Parts", "Frypan Head", 14035).getInt(14035);
signHead = config.getItem("Tool Parts", "Sign Head", 14036).getInt(14036); signHead = config.getItem("Tool Parts", "Sign Head", 14036).getInt(14036);
lumberHead = config.getItem("Tool Parts", "Lumber Axe Head", 14036).getInt(14036); lumberHead = config.getItem("Tool Parts", "Lumber Axe Head", 14037).getInt(14037);
pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051); pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051);
shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052); shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052);

View File

@ -18,12 +18,12 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
/** TConstruct, the successor to InfiTools /** TConstruct, the tool mod.
* Now with many much more combinations and many much less IDs! * Craft your tools with style, then modify until the original is gone!
* @author: mDiyo * @author: mDiyo
*/ */
@Mod(modid = "TConstruct", name = "TConstruct", version = "A16") @Mod(modid = "TConstruct", name = "TConstruct", version = "A17")
@NetworkMod(serverSideRequired = false, clientSideRequired = true) @NetworkMod(serverSideRequired = false, clientSideRequired = true)
public class TConstruct public class TConstruct
{ {
@ -41,12 +41,12 @@ public class TConstruct
{ {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
PHConstruct.initProps(); PHConstruct.initProps();
materialTab = new TabTools("TConMaterials"); materialTab = new TabTools("TConstructMaterials");
toolTab = new TabTools("TConstruct"); toolTab = new TabTools("TConstructTools");
blockTab = new TabTools("TConstructBlocks"); blockTab = new TabTools("TConstructBlocks");
content = new TConstructContent(); content = new TConstructContent();
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.instance().registerGuiHandler(instance, new TConstructGuiHandler());
addToolButtons(); addToolButtons();
} }

View File

@ -4,6 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
@ -122,15 +123,15 @@ public class TConstructContent
GameRegistry.registerBlock(smeltery, "Smeltery"); GameRegistry.registerBlock(smeltery, "Smeltery");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.SmelteryLogic.class, "TConstruct.Smeltery"); GameRegistry.registerTileEntity(tinker.tconstruct.logic.SmelteryLogic.class, "TConstruct.Smeltery");
craftedSoil = new TConstructBlock(PHConstruct.craftedSoil, 96, Material.sand, 3.0F); craftedSoil = new TConstructBlock(PHConstruct.craftedSoil, 96, Material.sand, 3.0F, 2);
craftedSoil.stepSound = Block.soundGravelFootstep; craftedSoil.stepSound = Block.soundGravelFootstep;
GameRegistry.registerBlock(craftedSoil, tinker.tconstruct.blocks.CraftedSoilItemBlock.class, "CraftedSoil"); GameRegistry.registerBlock(craftedSoil, tinker.tconstruct.blocks.CraftedSoilItemBlock.class, "CraftedSoil");
searedBrick = new TConstructBlock(PHConstruct.searedBrick, 80, Material.iron, 10.0F); searedBrick = new TConstructBlock(PHConstruct.searedBrick, 80, Material.iron, 10.0F, 1);
GameRegistry.registerBlock(searedBrick, tinker.tconstruct.blocks.SearedBrickItemBlock.class, "SearedBrick"); GameRegistry.registerBlock(searedBrick, tinker.tconstruct.blocks.SearedBrickItemBlock.class, "SearedBrick");
MinecraftForge.setBlockHarvestLevel(searedBrick, 0, "pickaxe", 2); MinecraftForge.setBlockHarvestLevel(searedBrick, 0, "pickaxe", 2);
materials = new Materials(PHConstruct.materials, 64, craftingTexture).setItemName("tconstruct.Materials"); materials = new Materials(PHConstruct.materials, 128, craftingTexture).setItemName("tconstruct.Materials");
toolRod = new ToolPart(PHConstruct.toolRod, 0, craftingTexture).setItemName("tconstruct.ToolRod"); toolRod = new ToolPart(PHConstruct.toolRod, 0, craftingTexture).setItemName("tconstruct.ToolRod");
toolShard = new ToolPart(PHConstruct.toolShard, 64, craftingTexture).setItemName("tconstruct.ToolShard"); toolShard = new ToolPart(PHConstruct.toolShard, 64, craftingTexture).setItemName("tconstruct.ToolShard");
woodPattern = new Pattern(PHConstruct.woodPattern, 0, patternTexture).setItemName("tconstruct.Pattern"); woodPattern = new Pattern(PHConstruct.woodPattern, 0, patternTexture).setItemName("tconstruct.Pattern");
@ -176,8 +177,8 @@ public class TConstructContent
pb.registerFullMaterial(Item.bone, 2, "bone", new ItemStack(toolShard, 1, 5), new ItemStack(Item.bone), 5); pb.registerFullMaterial(Item.bone, 2, "bone", new ItemStack(toolShard, 1, 5), new ItemStack(Item.bone), 5);
pb.registerFullMaterial(Block.obsidian, 2, "obsidian", 6); pb.registerFullMaterial(Block.obsidian, 2, "obsidian", 6);
pb.registerFullMaterial(Block.netherrack, 2, "netherrack", 7); pb.registerFullMaterial(Block.netherrack, 2, "netherrack", 7);
pb.registerFullMaterial(Item.slimeBall, 2, "slime", 8); //TODO: Register a better material pb.registerFullMaterial(new ItemStack(materials, 1, 1), 2, "slime", new ItemStack(toolShard, 1, 8), new ItemStack(toolRod, 1, 8), 8);
pb.registerFullMaterial(Item.paper, 2, "paper", new ItemStack(Item.paper), new ItemStack(toolRod, 1, 9), 9); //TODO: Register a better material pb.registerFullMaterial(new ItemStack(materials, 1, 0), 2, "paper", new ItemStack(Item.paper), new ItemStack(toolRod, 1, 9), 9);
Item[] items = { toolRod, pickaxeHead, shovelHead, axeHead, swordBlade, largeGuard, medGuard, crossbar, binding, frypanHead, signHead, lumberHead }; Item[] items = { toolRod, pickaxeHead, shovelHead, axeHead, swordBlade, largeGuard, medGuard, crossbar, binding, frypanHead, signHead, lumberHead };
for (int iter = 0; iter < items.length; iter++) for (int iter = 0; iter < items.length; iter++)
@ -241,6 +242,14 @@ public class TConstructContent
GameRegistry.addRecipe(new ItemStack(stonePattern, 1, 0), "ps", "sp", 'p', Block.stone, 's', new ItemStack(toolRod, 1, 1)); GameRegistry.addRecipe(new ItemStack(stonePattern, 1, 0), "ps", "sp", 'p', Block.stone, 's', new ItemStack(toolRod, 1, 1));
GameRegistry.addRecipe(new ItemStack(netherPattern, 1, 0), "ps", "sp", 'p', Block.netherrack, 's', new ItemStack(toolRod, 1, 7));*/ GameRegistry.addRecipe(new ItemStack(netherPattern, 1, 0), "ps", "sp", 'p', Block.netherrack, 's', new ItemStack(toolRod, 1, 7));*/
GameRegistry.addRecipe(new ItemStack(materials, 1, 0), "pp", "pp", 'p', Item.paper);
GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 1, 0), Item.slimeBall, Item.slimeBall, Item.slimeBall, Item.slimeBall, Block.sand, Block.dirt);
GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 1, 1), Item.clay, Block.sand, Block.dirt); //Add stone dust?
FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 0, new ItemStack(materials, 1, 1), 2f); //Slime
FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 1, new ItemStack(materials, 1, 2), 2f); //Seared brick item
GameRegistry.addRecipe(new ItemStack(searedBrick, 1, 0), "pp", "pp", 'p', new ItemStack(materials, 1, 2)); //Seared brick block
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
GameRegistry.addRecipe(new ItemStack(TConstructContent.woodPattern, 1, i + 1), "s", 's', new ItemStack(TConstructContent.woodPattern, 1, i)); GameRegistry.addRecipe(new ItemStack(TConstructContent.woodPattern, 1, i + 1), "s", 's', new ItemStack(TConstructContent.woodPattern, 1, i));

View File

@ -4,23 +4,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.common.InventoryLogic; import tinker.common.InventoryLogic;
import tinker.tconstruct.client.gui.FrypanGui; import tinker.tconstruct.client.gui.*;
import tinker.tconstruct.client.gui.PartCrafterGui; import tinker.tconstruct.logic.*;
import tinker.tconstruct.client.gui.PatternChestGui;
import tinker.tconstruct.client.gui.ToolStationGui;
import tinker.tconstruct.logic.FrypanLogic;
import tinker.tconstruct.logic.PartCrafterLogic;
import tinker.tconstruct.logic.PatternChestLogic;
import tinker.tconstruct.logic.ToolStationLogic;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler public class TConstructGuiHandler implements IGuiHandler
{ {
int stationID = 0; public static int stationID = 0;
int partID = 1; public static int partID = 1;
int pchestID = 2; public static int pchestID = 2;
int smeltery = 3; public static int smeltery = 3;
int frypanID = 4; public static int frypanID = 4;
@Override @Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
@ -40,6 +34,8 @@ public class GuiHandler implements IGuiHandler
return new PartCrafterGui(player.inventory, (PartCrafterLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); return new PartCrafterGui(player.inventory, (PartCrafterLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == pchestID) if (ID == pchestID)
return new PatternChestGui(player.inventory, (PatternChestLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); return new PatternChestGui(player.inventory, (PatternChestLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == smeltery)
return new SmelteryGui(player.inventory, (SmelteryLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == frypanID) if (ID == frypanID)
return new FrypanGui(player.inventory, (FrypanLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); return new FrypanGui(player.inventory, (FrypanLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
return null; return null;

View File

@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.common.InventoryBlock; import tinker.common.InventoryBlock;
import tinker.tconstruct.TConstructGuiHandler;
import tinker.tconstruct.TConstruct; import tinker.tconstruct.TConstruct;
import tinker.tconstruct.logic.FrypanLogic; import tinker.tconstruct.logic.FrypanLogic;
@ -90,8 +91,8 @@ public class EquipBlock extends InventoryBlock
@Override @Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{ {
int md = world.getBlockMetadata(x, y, z); //int md = world.getBlockMetadata(x, y, z);
return 3; return TConstructGuiHandler.frypanID;
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package tinker.tconstruct.blocks; package tinker.tconstruct.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -18,6 +19,7 @@ public class LavaTankBlock extends BlockContainer
super(id, 49, Material.iron); super(id, 49, Material.iron);
setCreativeTab(TConstruct.blockTab); setCreativeTab(TConstruct.blockTab);
setBlockName("TConstruct.LavaTank"); setBlockName("TConstruct.LavaTank");
setStepSound(Block.soundGlassFootstep);
} }
@Override @Override
@ -51,7 +53,7 @@ public class LavaTankBlock extends BlockContainer
if (liquid != null) if (liquid != null)
{ {
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
int amount = logic.fill(0, liquid, true); int amount = logic.fill(liquid, true);
if (amount > 0) if (amount > 0)
return true; return true;
else else

View File

@ -27,6 +27,7 @@ public class SmelteryBlock extends InventoryBlock
setStepSound(soundMetalFootstep); setStepSound(soundMetalFootstep);
rand = new Random(); rand = new Random();
this.setCreativeTab(TConstruct.blockTab); this.setCreativeTab(TConstruct.blockTab);
this.setBlockName("tconstruct.Smeltery");
} }
public String getTextureFile () public String getTextureFile ()
@ -166,6 +167,12 @@ public class SmelteryBlock extends InventoryBlock
public void onBlockPlacedElsewhere(World world, int x, int y, int z, EntityLiving entityliving) public void onBlockPlacedElsewhere(World world, int x, int y, int z, EntityLiving entityliving)
{ {
SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z); SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z);
logic.scanWorld(); logic.checkValidPlacement();
}
@Override
public void breakBlock (World world, int x, int y, int z, int par5, int par6) //Don't drop inventory
{
world.removeBlockTileEntity(x, y, z);
} }
} }

View File

@ -1,16 +1,23 @@
package tinker.tconstruct.blocks; package tinker.tconstruct.blocks;
import tinker.tconstruct.TConstructContent; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.TConstructContent;
public class TConstructBlock extends Block public class TConstructBlock extends Block
{ {
int subblocks;
public TConstructBlock(int id, int tex, Material material, float hardness) public TConstructBlock(int id, int tex, Material material, float hardness, int sub)
{ {
super(id, tex, material); super(id, tex, material);
setHardness(hardness); setHardness(hardness);
this.setCreativeTab(TConstruct.blockTab);
subblocks = sub;
} }
@Override @Override
@ -31,4 +38,12 @@ public class TConstructBlock extends Block
return TConstructContent.blockTexture; return TConstructContent.blockTexture;
} }
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < subblocks; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
} }

View File

@ -42,18 +42,24 @@ public class TProxyClient extends TProxyCommon
public void addNames() public void addNames()
{ {
LanguageRegistry.addName(TConstructContent.lavaTank, "Lava Tank"); LanguageRegistry.addName(TConstructContent.lavaTank, "Lava Tank");
LanguageRegistry.instance().addStringLocalization("itemGroup.TConstruct", "TConstruct Tools"); LanguageRegistry.instance().addStringLocalization("itemGroup.TConstructTools", "TConstruct Tools");
LanguageRegistry.instance().addStringLocalization("itemGroup.TConMaterials", "TConstruct Materials"); LanguageRegistry.instance().addStringLocalization("itemGroup.TConstructMaterials", "TConstruct Materials");
LanguageRegistry.instance().addStringLocalization("itemGroup.TConstructBlocks", "TConstruct Blocks");
LanguageRegistry.instance().addStringLocalization("crafters.ToolStation", "Tool Station"); LanguageRegistry.instance().addStringLocalization("crafters.ToolStation", "Tool Station");
LanguageRegistry.instance().addStringLocalization("crafters.PartBuilder", "Part Builder"); LanguageRegistry.instance().addStringLocalization("crafters.PartBuilder", "Part Builder");
LanguageRegistry.instance().addStringLocalization("inventory.PatternChest", "Pattern Chest"); LanguageRegistry.instance().addStringLocalization("inventory.PatternChest", "Pattern Chest");
LanguageRegistry.instance().addStringLocalization("crafters.Smeltery", "Smeltery");
LanguageRegistry.instance().addStringLocalization("crafters.Frypan", "Frying Pan"); LanguageRegistry.instance().addStringLocalization("crafters.Frypan", "Frying Pan");
LanguageRegistry.instance().addStringLocalization("ToolStation.Crafter.name", "Tool Station"); LanguageRegistry.instance().addStringLocalization("ToolStation.Crafter.name", "Tool Station");
LanguageRegistry.instance().addStringLocalization("ToolStation.Parts.name", "Part Crafting"); LanguageRegistry.instance().addStringLocalization("ToolStation.Parts.name", "Part Crafting");
LanguageRegistry.instance().addStringLocalization("ToolStation.PatternChest.name", "Pattern Chest"); LanguageRegistry.instance().addStringLocalization("ToolStation.PatternChest.name", "Pattern Chest");
LanguageRegistry.instance().addStringLocalization("CraftedSoil.Slime.name", "Slimy Mud");
LanguageRegistry.instance().addStringLocalization("CraftedSoil.Grout.name", "Grout");
LanguageRegistry.instance().addStringLocalization("SearedBrick.Brick.name", "Seared Bricks");
for (int mat = 0; mat < materialTypes.length; mat++) for (int mat = 0; mat < materialTypes.length; mat++)
{ {
for (int type = 0; type < toolMaterialNames.length; type++) for (int type = 0; type < toolMaterialNames.length; type++)
@ -64,6 +70,13 @@ public class TProxyClient extends TProxyCommon
} }
} }
for (int i = 0; i < materialItemNames.length; i++)
{
String internalName = "item.tconstruct.Materials."+materialItemInternalNames[i]+".name";
String visibleName = materialItemNames[i];
LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName);
}
for (int i = 0; i < patterns.length; i++) for (int i = 0; i < patterns.length; i++)
{ {
String internalName = "item.tconstruct.Pattern."+patterns[i]+".name"; String internalName = "item.tconstruct.Pattern."+patterns[i]+".name";
@ -71,6 +84,8 @@ public class TProxyClient extends TProxyCommon
LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName);
} }
LanguageRegistry.addName(TConstructContent.smeltery, "Smeltery");
LanguageRegistry.addName(TConstructContent.pickaxe, "Pickaxe"); LanguageRegistry.addName(TConstructContent.pickaxe, "Pickaxe");
LanguageRegistry.addName(TConstructContent.shovel, "Shovel"); LanguageRegistry.addName(TConstructContent.shovel, "Shovel");
LanguageRegistry.addName(TConstructContent.axe, "Axe"); LanguageRegistry.addName(TConstructContent.axe, "Axe");
@ -89,6 +104,11 @@ public class TProxyClient extends TProxyCommon
return Minecraft.getMinecraftDir(); return Minecraft.getMinecraftDir();
} }
public static final String[] materialItemInternalNames = new String[] {
"PaperStack", "SlimeCrystal", "SearedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot" };
public static final String[] materialItemNames = new String[] {
"Paper Stack", "Slime Crystal", "Seared Brick", "Cobalt Ingot", "Ardite Ingot", "Manyullyn Ingot" };
public static final String[] toolMaterialNames = new String[] { public static final String[] toolMaterialNames = new String[] {
"Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn" }; "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn" };

View File

@ -30,12 +30,12 @@ public class TankRender implements ISimpleBlockRenderingHandler
{ {
renderer.renderStandardBlock(block, x, y, z); renderer.renderStandardBlock(block, x, y, z);
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
if (logic.amount > 0) if (logic.getLiquidAmount() > 0)
{ {
Block liquidBlock = Block.blocksList[logic.liquid.itemID]; Block liquidBlock = Block.blocksList[logic.liquid.itemID];
if (liquidBlock != null) if (liquidBlock != null)
{ {
renderer.setRenderBounds(0.03, 0.03, 0.03, 0.97, logic.amount/1020f, 0.97); renderer.setRenderBounds(0.03, 0.03, 0.03, 0.97, logic.getLiquidAmount()/1020f, 0.97);
renderer.renderStandardBlock(liquidBlock, x, y, z); renderer.renderStandardBlock(liquidBlock, x, y, z);
} }
} }

View File

@ -0,0 +1,123 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.logic.SmelteryLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
public class SmelteryContainer extends Container
{
public SmelteryLogic logic;
public int fuel = 0;
public SmelteryContainer(InventoryPlayer inventoryplayer, SmelteryLogic frypan)
{
logic = frypan;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
this.addSlotToContainer(new Slot(frypan, x + y*3, 62 + x*18, 15 + y*18));
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
/*for (int i = 0; i < crafters.size(); i++)
{
ICrafting icrafting = (ICrafting)crafters.get(i);
if (progress != logic.progress)
{
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
}
if (fuel != logic.fuel)
{
icrafting.sendProgressBarUpdate(this, 1, logic.fuel);
}
if (fuelGague != logic.fuelGague)
{
icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague);
}
}
progress = logic.progress;
fuel = logic.fuel;
fuelGague = logic.fuelGague;*/
}
public void updateProgressBar(int id, int value)
{
if (id == 0)
{
logic.fuelGague = value;
}
/* if (id == 1)
{
logic.fuel = value;
}*/
/*if (id == 2)
{
logic.fuelGague = value;
}*/
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return logic.isUseableByPlayer(entityplayer);
}
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
}

View File

@ -0,0 +1,58 @@
package tinker.tconstruct.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import tinker.tconstruct.logic.SmelteryLogic;
public class SmelteryGui extends GuiContainer
{
public SmelteryLogic logic;
public SmelteryGui(InventoryPlayer inventoryplayer, SmelteryLogic smeltery, World world, int x, int y, int z)
{
super(smeltery.getGuiContainer(inventoryplayer, world, x, y, z));
logic = smeltery;
}
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
fontRenderer.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 60, 5, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
drawStats();
}
void drawStats ()
{
fontRenderer.drawString("Temp: " + logic.getInternalTemperature(), xSize + 6, 6, 0xffffff);
for (int iter = 0; iter < 9; iter++)
fontRenderer.drawString("Slot "+iter+" temp: " + logic.getTempForSlot(iter), xSize + 6, 15+iter*9, 0xffffff);
}
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
{
int texID = mc.renderEngine.getTexture("/tinkertextures/gui/smeltery.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(texID);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
if (logic.fuelGague > 0)
{
int fuel = logic.getScaledFuelGague(52);
drawTexturedModalRect(cornerX + 146, (cornerY + 67) - fuel, 176, 52 - fuel, 14, fuel + 2);
}
// Draw description
texID = this.mc.renderEngine.getTexture("/tinkertextures/gui/description.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texID);
cornerX = (this.width + this.xSize) / 2;
cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
}
}

View File

@ -40,7 +40,7 @@ public class ToolStationGui extends GuiContainer
this.text.setVisible(true); this.text.setVisible(true);
this.text.setCanLoseFocus(false); this.text.setCanLoseFocus(false);
this.text.setFocused(true); this.text.setFocused(true);
this.text.setTextColor(16777215); this.text.setTextColor(0xffffff);
resetGui(); resetGui();
} }
@ -145,7 +145,7 @@ public class ToolStationGui extends GuiContainer
ItemStack stack = logic.getStackInSlot(0); ItemStack stack = logic.getStackInSlot(0);
ToolCore tool = (ToolCore) stack.getItem(); ToolCore tool = (ToolCore) stack.getItem();
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
this.drawCenteredString(fontRenderer, "\u00A7n"+tool.getToolName(), xSize + 63, 8, 16777215); this.drawCenteredString(fontRenderer, "\u00A7n"+tool.getToolName(), xSize + 63, 8, 0xffffff);
if (tool instanceof Weapon) if (tool instanceof Weapon)
drawWeaponStats(stack, tool, tags); drawWeaponStats(stack, tool, tags);
else if (tool.getHeadType() == 3) else if (tool.getHeadType() == 3)
@ -159,13 +159,13 @@ public class ToolStationGui extends GuiContainer
int dur = tags.getInteger("Damage"); int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability"); int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur; dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215); fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
int damage = tags.getInteger("Attack"); int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 16777215); fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 57, 16777215); fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 57, 0xffffff);
if (tags.hasKey("Tooltip1")); if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 68, 16777215); fontRenderer.drawString("Modifiers:", xSize + 8, 68, 0xffffff);
boolean displayToolTips = true; boolean displayToolTips = true;
int tipNum = 0; int tipNum = 0;
@ -176,7 +176,7 @@ public class ToolStationGui extends GuiContainer
if (tags.hasKey(tooltip)) if (tags.hasKey(tooltip))
{ {
String tipName = tags.getString(tooltip); String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 68 + tipNum*11, 16777215); fontRenderer.drawString("- "+tipName, xSize + 8, 68 + tipNum*11, 0xffffff);
} }
else else
displayToolTips = false; displayToolTips = false;
@ -188,16 +188,16 @@ public class ToolStationGui extends GuiContainer
int dur = tags.getInteger("Damage"); int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability"); int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur; dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215); fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
int damage = tags.getInteger("Attack"); int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 16777215); fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 0xffffff);
float mineSpeed = tags.getInteger("MiningSpeed") / 100f; float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 46, 16777215); fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 46, 0xffffff);
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 57, 16777215); fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 57, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 79, 16777215); fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 79, 0xffffff);
if (tags.hasKey("Tooltip1")); if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 90, 16777215); fontRenderer.drawString("Modifiers:", xSize + 8, 90, 0xffffff);
boolean displayToolTips = true; boolean displayToolTips = true;
int tipNum = 0; int tipNum = 0;
@ -208,7 +208,7 @@ public class ToolStationGui extends GuiContainer
if (tags.hasKey(tooltip)) if (tags.hasKey(tooltip))
{ {
String tipName = tags.getString(tooltip); String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 90 + tipNum*11, 16777215); fontRenderer.drawString("- "+tipName, xSize + 8, 90 + tipNum*11, 0xffffff);
} }
else else
displayToolTips = false; displayToolTips = false;
@ -220,18 +220,18 @@ public class ToolStationGui extends GuiContainer
int dur = tags.getInteger("Damage"); int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability"); int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur; dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215); fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
float mineSpeed = tags.getInteger("MiningSpeed") / 100f; float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f; float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
fontRenderer.drawString("Mining Speeds: ", xSize + 8, 35, 16777215); fontRenderer.drawString("Mining Speeds: ", xSize + 8, 35, 0xffffff);
fontRenderer.drawString("- "+mineSpeed+", "+mineSpeed2, xSize + 8, 46, 16777215); fontRenderer.drawString("- "+mineSpeed+", "+mineSpeed2, xSize + 8, 46, 0xffffff);
fontRenderer.drawString("Harvest Levels:", xSize + 8, 57, 16777215); fontRenderer.drawString("Harvest Levels:", xSize + 8, 57, 0xffffff);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 68, 16777215); fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 68, 0xffffff);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, 79, 16777215); fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, 79, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 90, 16777215); fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 90, 0xffffff);
if (tags.hasKey("Tooltip1")); if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 101, 16777215); fontRenderer.drawString("Modifiers:", xSize + 8, 101, 0xffffff);
boolean displayToolTips = true; boolean displayToolTips = true;
int tipNum = 0; int tipNum = 0;
@ -242,7 +242,7 @@ public class ToolStationGui extends GuiContainer
if (tags.hasKey(tooltip)) if (tags.hasKey(tooltip))
{ {
String tipName = tags.getString(tooltip); String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 101 + tipNum*11, 16777215); fontRenderer.drawString("- "+tipName, xSize + 8, 101 + tipNum*11, 0xffffff);
} }
else else
displayToolTips = false; displayToolTips = false;
@ -251,8 +251,8 @@ public class ToolStationGui extends GuiContainer
void drawToolInformation () void drawToolInformation ()
{ {
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 16777215); this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 0xffffff);
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 16777215); fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 0xffffff);
} }
String getHarvestLevelName (int num) String getHarvestLevelName (int num)

View File

@ -1,6 +1,6 @@
package tinker.tconstruct.crafting; package tinker.tconstruct.crafting;
/** How to build tool parts? With patterns! */
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View File

@ -0,0 +1,81 @@
package tinker.tconstruct.crafting;
import java.util.*;
import net.minecraft.item.ItemStack;
/** Melting and hacking, churn and burn */
public class Smeltery
{
public static Smeltery instance = new Smeltery();
private HashMap<List<Integer>, ItemStack> smeltingList = new HashMap<List<Integer>, ItemStack>();
private HashMap<List<Integer>, Integer> temperatureList = new HashMap<List<Integer>, Integer>();
/** Adds a mapping between an input and an itemstack
*
* @param itemID The block or item's main ID
* @param metadata Damage or use
* @param itemstack
*/
public static void addSmelting(int itemID, int metadata, int temperature, ItemStack itemstack)
{
instance.smeltingList.put(Arrays.asList(itemID, metadata), itemstack);
instance.temperatureList.put(Arrays.asList(itemID, metadata), temperature);
}
/**
* Used to get the resulting temperature from a source ItemStack
* @param item The Source ItemStack
* @return The result temperature
*/
public static Integer getSmeltingTemperature(ItemStack item)
{
if (item == null)
return null;
return instance.temperatureList.get(Arrays.asList(item.itemID, item.getItemDamage()));
}
public static Integer getSmeltingTemperature(int blockID)
{
return getSmeltingTemperature(blockID, 0);
}
/**
* Used to get the resulting temperature from a source Block
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static Integer getSmeltingTemperature(int blockID, int metadata)
{
return instance.temperatureList.get(Arrays.asList(blockID, metadata));
}
/**
* Used to get the resulting ItemStack from a source ItemStack
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static ItemStack getSmeltingResult(ItemStack item)
{
if (item == null)
return null;
return (ItemStack) instance.smeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())).copy();
}
public static ItemStack getSmeltingResult(int blockID)
{
return getSmeltingResult(blockID, 0);
}
/**
* Used to get the resulting ItemStack from a source Block
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static ItemStack getSmeltingResult(int blockID, int metadata)
{
return (ItemStack) instance.smeltingList.get(Arrays.asList(blockID, metadata)).copy();
}
}

View File

@ -1,6 +1,6 @@
package tinker.tconstruct.crafting; package tinker.tconstruct.crafting;
/** Once upon a time, too many tools to count. Let's put them together automatically */
import java.util.*; import java.util.*;
import tinker.tconstruct.EnumMaterial; import tinker.tconstruct.EnumMaterial;

View File

@ -39,5 +39,5 @@ public class Materials extends Item
} }
public static final String[] materialNames = new String[] { public static final String[] materialNames = new String[] {
"PaperStack", "SlimeCrystal", "HardenedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot" }; "PaperStack", "SlimeCrystal", "SearedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot" };
} }

View File

@ -7,81 +7,86 @@ import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank; import net.minecraftforge.liquids.LiquidTank;
public class LavaTankLogic extends TileEntity public class LavaTankLogic extends TileEntity
implements ITankContainer implements ILiquidTank
{ {
public LiquidTank tank; public LiquidTank tank;
public int amount;
public int max; public int max;
public int pressure;
public LiquidStack liquid; public LiquidStack liquid;
public LavaTankLogic() public LavaTankLogic()
{ {
tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME); tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
max = 1; max = LiquidContainerRegistry.BUCKET_VOLUME;
amount = 0;
} }
@Override @Override
public int fill (ForgeDirection from, LiquidStack resource, boolean doFill) public LiquidStack getLiquid ()
{ {
return fill(0, resource, doFill); return liquid;
}
public int getLiquidAmount ()
{
if (liquid == null)
return 0;
else
return liquid.amount;
} }
@Override @Override
public int fill (int tankIndex, LiquidStack resource, boolean doFill) public int getCapacity ()
{
return max;
}
@Override
public int fill (LiquidStack resource, boolean doFill)
{ {
if (resource == null) if (resource == null)
return 0; return 0;
if (liquid == null) if (liquid == null)
{ {
liquid = resource; liquid = resource.copy();
amount = resource.amount;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return amount; return liquid.amount;
} }
else if (resource.amount + amount > max*1000) else if (resource.amount + liquid.amount > max)
{ {
if (doFill) if (doFill)
{ {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
amount = 4000; liquid.amount = max;
} }
return resource.amount + amount - 4000; return max - resource.amount;
} }
else else
{ {
if (doFill) if (doFill)
{ {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
amount += resource.amount; liquid.amount += resource.amount;
} }
return amount; return resource.amount;
} }
} }
@Override @Override
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) public LiquidStack drain (int maxDrain, boolean doDrain)
{ {
return drain(0, maxDrain, doDrain); if (liquid == null)
} return null;
if (liquid.amount - maxDrain < 0)
@Override
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
{
if (amount - maxDrain < 0)
{ {
LiquidStack liq = new LiquidStack(liquid.itemID, 0, liquid.itemMeta); LiquidStack liq = liquid.copy();
if (doDrain) if (doDrain)
{ {
amount = 0;
liquid = null; liquid = null;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
} }
@ -91,29 +96,22 @@ public class LavaTankLogic extends TileEntity
{ {
if (doDrain) if (doDrain)
{ {
amount -= maxDrain; liquid.amount -= maxDrain;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
} }
return new LiquidStack(liquid.itemID, amount - maxDrain, liquid.itemMeta); return new LiquidStack(liquid.itemID, maxDrain, liquid.itemMeta);
} }
} }
@Override @Override
public ILiquidTank[] getTanks (ForgeDirection direction) public int getTankPressure ()
{ {
return new ILiquidTank[] { (ILiquidTank) this }; return 0;
}
@Override
public ILiquidTank getTank (ForgeDirection direction, LiquidStack type)
{
return (ILiquidTank) this;
} }
public void readFromNBT(NBTTagCompound par1NBTTagCompound) public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{ {
this.amount = par1NBTTagCompound.getInteger("amount"); this.liquid = new LiquidStack(par1NBTTagCompound.getInteger("itemID"), par1NBTTagCompound.getInteger("amount"), par1NBTTagCompound.getInteger("itemMeta"));
this.liquid = new LiquidStack(par1NBTTagCompound.getInteger("itemID"), amount, par1NBTTagCompound.getInteger("itemMeta"));
super.readFromNBT(par1NBTTagCompound); super.readFromNBT(par1NBTTagCompound);
} }
@ -122,7 +120,7 @@ public class LavaTankLogic extends TileEntity
if (liquid != null) if (liquid != null)
{ {
par1NBTTagCompound.setInteger("itemID", liquid.itemID); par1NBTTagCompound.setInteger("itemID", liquid.itemID);
par1NBTTagCompound.setInteger("amount", this.amount); par1NBTTagCompound.setInteger("amount", liquid.amount);
par1NBTTagCompound.setInteger("itemMeta", liquid.itemMeta); par1NBTTagCompound.setInteger("itemMeta", liquid.itemMeta);
} }
else else

View File

@ -3,10 +3,22 @@ package tinker.tconstruct.logic;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.LiquidStack;
import tinker.common.IActiveLogic; import tinker.common.IActiveLogic;
import tinker.common.IFacingLogic; import tinker.common.IFacingLogic;
import tinker.common.InventoryLogic; import tinker.common.InventoryLogic;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.client.gui.SmelteryContainer;
import tinker.tconstruct.crafting.Smeltery;
/* Simple class for storing items in the block /* Simple class for storing items in the block
*/ */
@ -14,15 +26,25 @@ import tinker.common.InventoryLogic;
public class SmelteryLogic extends InventoryLogic public class SmelteryLogic extends InventoryLogic
implements IActiveLogic, IFacingLogic implements IActiveLogic, IFacingLogic
{ {
int temperature; boolean validStructure;
int useTime;
byte direction; byte direction;
int internalTemp;
int maxTemp;
int useTime;
public int fuelGague;
int[] tankCoords;
int[] bottomTemps;
int tick;
public SmelteryLogic() public SmelteryLogic()
{ {
super(5); super(9);
bottomTemps = new int[9];
for (int i = 0; i < 9; i++)
bottomTemps[i] = 20;
} }
/* Misc */
@Override @Override
public String getInvName () public String getInvName ()
{ {
@ -32,7 +54,7 @@ public class SmelteryLogic extends InventoryLogic
@Override @Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{ {
return null; return new SmelteryContainer(inventoryplayer, this);
} }
@Override @Override
@ -50,7 +72,7 @@ public class SmelteryLogic extends InventoryLogic
@Override @Override
public boolean getActive() public boolean getActive()
{ {
return false; return validStructure;
} }
@Override @Override
@ -65,40 +87,313 @@ public class SmelteryLogic extends InventoryLogic
return false; return false;
} }
public void scanWorld() public int getScaledFuelGague (int scale)
{
return (fuelGague * scale) / 52;
}
public int getInternalTemperature ()
{
return internalTemp;
}
public int getTempForSlot (int slot)
{
return bottomTemps[slot];
}
/* Updating */
public void updateEntity ()
{
tick++;
if (tick % 4 == 0)
updateTemperatures();
if (tick == 20)
{
tick = 0;
checkValidPlacement();
updateFuelGague();
if (useTime > 0)
useTime--;
if (!worldObj.isRemote)
matchInventoryToWorld();
if (validStructure && useTime == 0)
{
TileEntity tank = worldObj.getBlockTileEntity(tankCoords[0], tankCoords[1], tankCoords[2]);
if (tank instanceof ILiquidTank)
{
LiquidStack liquid = ((ILiquidTank)tank).drain(10, true);
if (liquid != null)
{
System.out.println("Drained "+liquid.amount);
useTime += liquid.amount;
}
}
}
}
}
void updateTemperatures()
{
for (int i = 0; i < 9; i++)
{
if (this.isStackInSlot(i) && bottomTemps[i] < internalTemp)
bottomTemps[i] += 1;
else
bottomTemps[i] = 20;
}
}
void updateFuelGague()
{
if (tankCoords == null || tankCoords.length < 3)
return;
TileEntity tank = worldObj.getBlockTileEntity(tankCoords[0], tankCoords[1], tankCoords[2]);
if (tank == null)
{
fuelGague = 0;
}
if (tank instanceof ILiquidTank)
{
LiquidStack liquid = ((ILiquidTank)tank).getLiquid();
int capacity = ((ILiquidTank)tank).getCapacity();
if (liquid != null)
fuelGague = liquid.amount * 52 / capacity;
else
fuelGague = 0;
}
}
public ItemStack getResultFor (ItemStack stack)
{
ItemStack result = Smeltery.instance.getSmeltingResult(stack);
if (result != null)
return result;
return null;
}
/* Inventory */
public int getInventoryStackLimit ()
{
return 1;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
setWorldToInventory();
}
@Override
public ItemStack decrStackSize(int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
setWorldToInventory();
return stack;
}
/* World-inventory matching */
void matchInventoryToWorld()
{ {
switch(getDirection()) switch(getDirection())
{ {
case 2: // +z case 2: // +z
//worldObj.setBlockWithNotify(xCoord, yCoord, zCoord+1, Block.dirt.blockID); grabWorldBlocks(xCoord, yCoord, zCoord+2);
placeBlockRing(xCoord, yCoord, zCoord+2);
break; break;
case 3: // -z case 3: // -z
//worldObj.setBlockWithNotify(xCoord, yCoord, zCoord-1, Block.dirt.blockID); grabWorldBlocks(xCoord, yCoord, zCoord-2);
placeBlockRing(xCoord, yCoord, zCoord-2);
break; break;
case 4: // +x case 4: // +x
//worldObj.setBlockWithNotify(xCoord+1, yCoord, zCoord, Block.dirt.blockID); grabWorldBlocks(xCoord+2, yCoord, zCoord);
placeBlockRing(xCoord+2, yCoord, zCoord);
break; break;
case 5: // -x case 5: // -x
//worldObj.setBlockWithNotify(xCoord-1, yCoord, zCoord, Block.dirt.blockID); grabWorldBlocks(xCoord-2, yCoord, zCoord);
placeBlockRing(xCoord-2, yCoord, zCoord);
break; break;
} }
} }
public void placeBlockRing(int x, int y, int z) void setWorldToInventory()
{ {
switch(getDirection())
{
case 2: // +z
setWorldToInventory(xCoord, yCoord, zCoord+2);
break;
case 3: // -z
setWorldToInventory(xCoord, yCoord, zCoord-2);
break;
case 4: // +x
setWorldToInventory(xCoord+2, yCoord, zCoord);
break;
case 5: // -x
setWorldToInventory(xCoord-2, yCoord, zCoord);
break;
}
}
public void grabWorldBlocks(int x, int y, int z)
{
for (int xPos = 0; xPos <= 2; xPos++)
{
for (int zPos = 0; zPos <= 2; zPos++)
{
int bID = worldObj.getBlockId(xPos+x-1, y, zPos+z-1);
ItemStack stack = inventory[xPos+zPos*3];
if (bID == 0)
inventory[xPos+zPos*3] = null;
else if (stack == null || stack.itemID != bID)
inventory[xPos+zPos*3] = new ItemStack(bID, 1, worldObj.getBlockMetadata(xPos+x-1, y, zPos+z-1));
}
}
}
public void setWorldToInventory(int x, int y, int z)
{
for (int xPos = 0; xPos <= 2; xPos++)
{
for (int zPos = 0; zPos <= 2; zPos++)
{
ItemStack stack = inventory[xPos+zPos*3];
if (stack == null)
worldObj.setBlockWithNotify(xPos+x-1, y, zPos+z-1, 0);
else if (stack.itemID < Block.blocksList.length && Block.blocksList[stack.itemID] != null)
worldObj.setBlockAndMetadataWithNotify(xPos+x-1, y, zPos+z-1, stack.itemID, stack.getItemDamage());
}
}
}
public void checkValidPlacement()
{
switch(getDirection())
{
case 2: // +z
checkValidStructure(xCoord, yCoord, zCoord+2);
break;
case 3: // -z
checkValidStructure(xCoord, yCoord, zCoord-2);
break;
case 4: // +x
checkValidStructure(xCoord+2, yCoord, zCoord);
break;
case 5: // -x
checkValidStructure(xCoord-2, yCoord, zCoord);
break;
}
}
public void checkValidStructure(int x, int y, int z)
{
int numBricks = 0;
boolean lavaTank = false;
//Check outer layer
for (int xPos = x-1; xPos <= x+1; xPos++) for (int xPos = x-1; xPos <= x+1; xPos++)
{ {
worldObj.setBlockWithNotify(xPos, y, z-2, Block.dirt.blockID); int southID = worldObj.getBlockId(xPos, y, z-2);
worldObj.setBlockWithNotify(xPos, y, z+2, Block.dirt.blockID); int northID = worldObj.getBlockId(xPos, y, z+2);
if (southID == TConstructContent.searedBrick.blockID)
numBricks++;
else if (southID == TConstructContent.lavaTank.blockID)
{
tankCoords = new int[] {xPos, y, z-2};
lavaTank = true;
}
if (northID == TConstructContent.searedBrick.blockID)
numBricks++;
else if (northID == TConstructContent.lavaTank.blockID)
{
tankCoords = new int[] {xPos, y, z+2};
lavaTank = true;
}
} }
for (int zPos = z-1; zPos <= z+1; zPos++) for (int zPos = z-1; zPos <= z+1; zPos++)
{ {
worldObj.setBlockWithNotify(x-2, y, zPos, Block.dirt.blockID); int westID = worldObj.getBlockId(x-2, y, zPos);
worldObj.setBlockWithNotify(x+2, y, zPos, Block.dirt.blockID); int eastID = worldObj.getBlockId(x+2, y, zPos);
if (westID == TConstructContent.searedBrick.blockID)
numBricks++;
else if (westID == TConstructContent.lavaTank.blockID)
{
tankCoords = new int[] {x-2, y, zPos};
lavaTank = true;
}
if (eastID == TConstructContent.searedBrick.blockID)
numBricks++;
else if (eastID == TConstructContent.lavaTank.blockID)
{
tankCoords = new int[] {x+2, y, zPos};
lavaTank = true;
}
}
//Check floor
for (int xPos = x-1; xPos <= x+1; xPos++)
{
for (int zPos = z-1; zPos <= z+1; zPos++)
{
if (worldObj.getBlockId(xPos, y-1, zPos) == TConstructContent.searedBrick.blockID)
numBricks++;
}
}
if (numBricks == 19 && lavaTank)
{
validStructure = true;
internalTemp = 550;
}
else
{
validStructure = false;
internalTemp = 20;
} }
} }
/* NBT */
@Override
public void readFromNBT(NBTTagCompound tags)
{
super.readFromNBT(tags);
validStructure = tags.getBoolean("ValidStructure");
direction = tags.getByte("Direction");
useTime = tags.getInteger("UseTime");
internalTemp = tags.getInteger("Temp");
tankCoords = tags.getIntArray("TankCoords");
}
@Override
public void writeToNBT(NBTTagCompound tags)
{
super.writeToNBT(tags);
tags.setBoolean("ValidStructure", validStructure);
tags.setByte("Direction", direction);
tags.setInteger("UseTime", useTime);
tags.setInteger("Temp", internalTemp);
tags.setIntArray("TankCoords", tankCoords);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
worldObj.getBlockTileEntity(xCoord, yCoord, zCoord).readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
} }

View File

@ -63,6 +63,8 @@ public class ModRepair extends ToolMod
damage = 0; damage = 0;
tags.setInteger("Damage", damage); tags.setInteger("Damage", damage);
tool.setItemDamage(damage * 100 / dur);
int repair = tags.getInteger("RepairCount"); int repair = tags.getInteger("RepairCount");
repair += 1; repair += 1;
tags.setInteger("RepairCount", repair); tags.setInteger("RepairCount", repair);

View File

@ -1,9 +1,11 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -44,4 +46,16 @@ public class Axe extends HarvestTool
} }
static Material[] materials = { Material.wood, Material.circuits, Material.cactus, Material.pumpkin }; static Material[] materials = { Material.wood, Material.circuits, Material.cactus, Material.pumpkin };
@Override
protected Item getHeadItem ()
{
return TConstructContent.axeHead;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -1,6 +1,7 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -8,6 +9,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -28,6 +30,11 @@ public class BattleSign extends Weapon
return stack; return stack;
} }
public String getToolName ()
{
return "Battle Sign";
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{ {
if (par7 == 0 || !player.isSneaking()) if (par7 == 0 || !player.isSneaking())
@ -97,4 +104,16 @@ public class BattleSign extends Weapon
} }
} }
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.signHead;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -1,9 +1,11 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -14,4 +16,16 @@ public class Broadsword extends Weapon
super(itemID, 4, tex); super(itemID, 4, tex);
this.setItemName("InfiTool.Broadsword"); this.setItemName("InfiTool.Broadsword");
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.swordBlade;
}
@Override
protected Item getAccessoryItem ()
{
return TConstructContent.largeGuard;
}
} }

View File

@ -2,6 +2,7 @@ package tinker.tconstruct.tools;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
@ -90,4 +91,16 @@ public class FryingPan extends Weapon
} }
} }
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.frypanHead;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
@ -82,4 +83,16 @@ public class Hammer extends HarvestTool
} }
return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, living, random); return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, living, random);
} }
@Override
protected Item getHeadItem ()
{
return null;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -1,11 +1,13 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction; import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -37,6 +39,18 @@ public class Longsword extends Weapon
AbilityHelper.thrust(stack, world, player); AbilityHelper.thrust(stack, world, player);
player.swingItem(); player.swingItem();
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.swordBlade;
}
@Override
protected Item getAccessoryItem ()
{
return TConstructContent.medGuard;
}
/*@Override /*@Override
public boolean hitEntity(ItemStack stack, EntityLiving mob, EntityLiving player) public boolean hitEntity(ItemStack stack, EntityLiving mob, EntityLiving player)

View File

@ -7,10 +7,12 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
public class LumberAxe extends HarvestTool public class LumberAxe extends HarvestTool
{ {
@ -157,4 +159,16 @@ public class LumberAxe extends HarvestTool
} }
} }
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.lumberHead;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -1,9 +1,11 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -52,4 +54,16 @@ public class Mattock extends DualHarvestTool
{ {
return AbilityHelper.hoeGround(stack, player, world, x, y, z, side, random); return AbilityHelper.hoeGround(stack, player, world, x, y, z, side, random);
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.axeHead;
}
@Override
protected Item getAccessoryItem ()
{
return TConstructContent.shovelHead;
}
} }

View File

@ -3,6 +3,7 @@ package tinker.tconstruct.tools;
import tinker.tconstruct.TConstructContent; import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
public class Pickaxe extends HarvestTool public class Pickaxe extends HarvestTool
{ {
@ -31,4 +32,16 @@ public class Pickaxe extends HarvestTool
} }
static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil }; static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil };
@Override
protected Item getHeadItem ()
{
return TConstructContent.pickaxeHead;
}
@Override
protected Item getAccessoryItem ()
{
return TConstructContent.binding;
}
} }

View File

@ -1,11 +1,13 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction; import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -15,7 +17,7 @@ public class Rapier extends Weapon
public Rapier(int itemID, String tex) public Rapier(int itemID, String tex)
{ {
super(itemID, 2, tex); super(itemID, 2, tex);
this.setItemName("InfiTool.FencingSword"); this.setItemName("InfiTool.Rapier");
} }
public EnumAction getItemUseAction(ItemStack par1ItemStack) public EnumAction getItemUseAction(ItemStack par1ItemStack)
@ -43,4 +45,16 @@ public class Rapier extends Weapon
{ {
return 0.7f; return 0.7f;
} }
@Override
protected Item getHeadItem ()
{
return TConstructContent.swordBlade;
}
@Override
protected Item getAccessoryItem ()
{
return TConstructContent.crossbar;
}
} }

View File

@ -1,6 +1,8 @@
package tinker.tconstruct.tools; package tinker.tconstruct.tools;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
public class Shovel extends HarvestTool public class Shovel extends HarvestTool
{ {
@ -29,4 +31,16 @@ public class Shovel extends HarvestTool
} }
static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
@Override
protected Item getHeadItem ()
{
return TConstructContent.shovelHead;
}
@Override
protected Item getAccessoryItem ()
{
return null;
}
} }

View File

@ -18,6 +18,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import tinker.tconstruct.AbilityHelper; import tinker.tconstruct.AbilityHelper;
import tinker.tconstruct.TConstruct; import tinker.tconstruct.TConstruct;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.crafting.ToolBuilder;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -307,31 +309,30 @@ public abstract class ToolCore extends Item
return ""; return "";
} }
} }
static String[] toolMaterialNames = {
"Wooden ", "Stone ", "Iron ", "Flint ", "Cactus ", "Bone ", "Obsidian ", "Nethrrack ", "Slime ", "Paper ", "Cobalt ", "Ardite ", "Manyullyn "
};
/* Creative mode tools */ /* Creative mode tools */
public void getSubItems (int id, CreativeTabs tab, List list) public void getSubItems (int id, CreativeTabs tab, List list)
{ {
/*for (int i = 0; i < 13; i++) for (int i = 0; i < 13; i++)
list.add(getDefaultItem(id, i));*/ {
Item accessory = getAccessoryItem();
ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, i) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, i), new ItemStack(getHandleItem(), 1, i), accessoryStack, toolMaterialNames[i]+getToolName());
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add( tool );
}
} }
ItemStack getDefaultItem (int id, int type) protected abstract Item getHeadItem();
protected abstract Item getAccessoryItem();
protected Item getHandleItem()
{ {
ItemStack tool = new ItemStack(id, 1, 0); return TConstructContent.toolRod;
NBTTagCompound compound = new NBTTagCompound();
compound.setCompoundTag("InfiTool", new NBTTagCompound());
compound.getCompoundTag("InfiTool").setInteger("Head", type);
compound.getCompoundTag("InfiTool").setInteger("Handle", 0);
compound.getCompoundTag("InfiTool").setInteger("Accessory", type);
compound.getCompoundTag("InfiTool").setInteger("Damage", 0);
compound.getCompoundTag("InfiTool").setInteger("MaxDamage", 20);
compound.getCompoundTag("InfiTool").setBoolean("Broken", false);
//compound.getCompoundTag("display").setString("Name", "Sword of Testing");
tool.setTagCompound(compound);
return tool;
} }
/* Tool uses */ /* Tool uses */

View File

@ -10,7 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
public class Weapon extends ToolCore public abstract class Weapon extends ToolCore
{ {
public Weapon(int itemID, int baseDamage, String texture) public Weapon(int itemID, int baseDamage, String texture)