Initial commit

This commit is contained in:
mDiyo committed 2013-01-18 23:43:53 -08:00
commit 8e3684ae99
118 files changed
+7790

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
Tinker's Workshop
Home of TConstruct
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

+7
View File
@@ -0,0 +1,7 @@
package tinker.common;
public interface IActiveLogic
{
public boolean getActive();
public void setActive(boolean flag);
}
+11
View File
@@ -0,0 +1,11 @@
package tinker.common;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
public interface IFacingLogic
{
public boolean canFaceVertical();
public byte getDirection();
public void setDirection(byte direction);
}
+6
View File
@@ -0,0 +1,6 @@
package tinker.common;
public interface IPattern
{
public int getPatternCost (int metadata);
}
+153
View File
@@ -0,0 +1,153 @@
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.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class InventoryBlock extends BlockContainer
{
protected InventoryBlock(int id, Material material)
{
super(id, material);
}
/* Logic backend */
public TileEntity createNewTileEntity (World var1) { return null; }
public abstract TileEntity createNewTileEntity(World world, int metadata);
public abstract Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer);
public abstract Object getModInstance();
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
{
if (player.isSneaking())
return false;
Integer integer = getGui(world, x, y, z, player);
if (integer == null || integer == -1)
{
return false;
}
else
{
player.openGui(getModInstance(), integer, world, x, y, z);
return true;
}
}
/* Inventory */
@Override
public void breakBlock (World par1World, int x, int y, int z, int par5, int par6)
{
InventoryLogic logic = (InventoryLogic) par1World.getBlockTileEntity(x, y, z);
if (logic != null)
{
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
{
ItemStack stack = logic.getStackInSlot(iter);
if (stack != null)
{
float jumpX = TConstruct.tRand.nextFloat() * 0.8F + 0.1F;
float jumpY = TConstruct.tRand.nextFloat() * 0.8F + 0.1F;
float jumpZ = TConstruct.tRand.nextFloat() * 0.8F + 0.1F;
while (stack.stackSize > 0)
{
int itemSize = TConstruct.tRand.nextInt(21) + 10;
if (itemSize > stack.stackSize)
{
itemSize = stack.stackSize;
}
stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ),
new ItemStack(stack.itemID, itemSize, stack.getItemDamage()));
if (stack.hasTagCompound())
{
entityitem.func_92014_d().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
float offset = 0.05F;
entityitem.motionX = (double) ((float) TConstruct.tRand.nextGaussian() * offset);
entityitem.motionY = (double) ((float) TConstruct.tRand.nextGaussian() * offset + 0.2F);
entityitem.motionZ = (double) ((float) TConstruct.tRand.nextGaussian() * offset);
par1World.spawnEntityInWorld(entityitem);
}
}
}
}
super.breakBlock(par1World, x, y, z, par5, par6);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
if (logic instanceof IFacingLogic)
{
IFacingLogic direction = (IFacingLogic) logic;
if (entityliving == null)
{
direction.setDirection((byte)1);
}
else
{
int facing = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
switch (facing)
{
case 0:
direction.setDirection((byte)2);
break;
case 1:
direction.setDirection((byte)5);
break;
case 2:
direction.setDirection((byte)3);
break;
case 3:
direction.setDirection((byte)4);
break;
}
if (direction.canFaceVertical())
{
//TODO: Vertical facing
}
}
}
}
public static boolean isActive(IBlockAccess world, int x, int y, int z)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
if (logic instanceof IActiveLogic)
{
return ((IActiveLogic)logic).getActive();
}
return false;
}
}
+142
View File
@@ -0,0 +1,142 @@
package tinker.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/*
* A simple logic class for storing items
* Abstract to avoid instantiation
*/
public abstract class InventoryLogic extends TileEntity
implements IInventory
{
protected ItemStack[] inventory;
public InventoryLogic(int invSize)
{
inventory = new ItemStack[invSize];
}
/* Inventory management */
@Override
public ItemStack getStackInSlot(int slot)
{
return inventory[slot];
}
public boolean isStackInSlot(int slot)
{
return inventory[slot] != null;
}
@Override
public int getSizeInventory()
{
return inventory.length;
}
@Override
public int getInventoryStackLimit ()
{
return 64;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
inventory[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize(int slot, int quantity)
{
if (inventory[slot] != null)
{
if (inventory[slot].stackSize <= quantity)
{
ItemStack stack = inventory[slot];
inventory[slot] = null;
return stack;
}
ItemStack split = inventory[slot].splitStack(quantity);
if (inventory[slot].stackSize == 0)
{
inventory[slot] = null;
}
return split;
}
else
{
return null;
}
}
/* Supporting methods */
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
return false;
else
return entityplayer.getDistance((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D;
}
public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z);
/* NBT */
@Override
public void readFromNBT(NBTTagCompound tags)
{
super.readFromNBT(tags);
NBTTagList nbttaglist = tags.getTagList("Items");
inventory = new ItemStack[getSizeInventory()];
for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
{
NBTTagCompound tagList = (NBTTagCompound)nbttaglist.tagAt(iter);
byte slotID = tagList.getByte("Slot");
if (slotID >= 0 && slotID < inventory.length)
{
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList);
}
}
}
@Override
public void writeToNBT(NBTTagCompound tags)
{
super.writeToNBT(tags);
NBTTagList nbttaglist = new NBTTagList();
for (int iter = 0; iter < inventory.length; iter++)
{
if (inventory[iter] != null)
{
NBTTagCompound tagList = new NBTTagCompound();
tagList.setByte("Slot", (byte)iter);
inventory[iter].writeToNBT(tagList);
nbttaglist.appendTag(tagList);
}
}
tags.setTag("Items", nbttaglist);
}
/* Default implementations of hardly used methods */
public ItemStack getStackInSlotOnClosing (int slot) { return null; }
public void openChest () {}
public void closeChest () {}
}
+320
View File
@@ -0,0 +1,320 @@
package tinker.tconstruct;
import ic2.api.ElectricItem;
import ic2.api.ICustomElectricItem;
import ic2.api.IElectricItem;
import ic2.core.util.StackUtil;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import tinker.tconstruct.tools.ToolCore;
import cpw.mods.fml.client.FMLClientHandler;
public class AbilityHelper
{
static Minecraft mc;
/* Blocks */
public static boolean onBlockChanged (ItemStack stack, World world, int bID, int x, int y, int z, EntityLiving player, Random random)
{
if (!stack.hasTagCompound())
return false;
int durability = 0;
NBTTagCompound tags = stack.getTagCompound();
if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking"))
durability = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
if (random.nextInt(10) < 10 - durability)
{
damageTool(stack, 1, tags, player);
}
return true;
}
/* Tool specific */
public static void damageTool (ItemStack stack, int dam, EntityLiving entity)
{
NBTTagCompound tags = stack.getTagCompound();
damageTool(stack, dam, tags, entity);
}
public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLiving entity)
{
if (!damageElectricTool(stack, tags, entity))
{
int damage = tags.getCompoundTag("InfiTool").getInteger("Damage");
int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
if ((damage + dam) > maxDamage)
{
breakTool(stack, tags, entity);
stack.setItemDamage(0);
}
else
{
tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam);
int toolDamage = damage * 100 / maxDamage + 1;
//System.out.println("Damage: " + damer);
int stackDamage = stack.getItemDamage();
if (toolDamage >= stackDamage && toolDamage < 100)
stack.damageItem(toolDamage - stackDamage, entity);
//stack.setItemDamage(damage * 100 / maxDamage + 1);
}
//stack.setItemDamage(1 + (maxDamage - damage) * (stack.getMaxDamage() - 1) / maxDamage);
}
}
public static boolean damageElectricTool (ItemStack stack, NBTTagCompound tags, Entity entity)
{
if (!tags.hasKey("charge"))
return false;
int charge = tags.getInteger("charge");
int mineSpeed = tags.getCompoundTag("InfiTool").getInteger("MiningSpeed");
if (tags.getCompoundTag("InfiTool").hasKey("MiningSpeed2"))
mineSpeed = (mineSpeed + tags.getCompoundTag("InfiTool").getInteger("MiningSpeed2")) / 2;
mineSpeed /= 15;
if (charge < mineSpeed)
{
if (charge > 0)
tags.setInteger("charge", 0);
return false;
}
/*if (entity instanceof EntityPlayer && ElectricItem.use(stack, mineSpeed, (EntityPlayer) entity))
return true;*/
charge -= mineSpeed;
ToolCore tool = (ToolCore) stack.getItem();
stack.setItemDamage(1 + (tool.getMaxCharge() - charge) * (stack.getMaxDamage() - 1) / tool.getMaxCharge());
tags.setInteger("charge", charge);
if (entity instanceof EntityPlayer)
chargeFromArmor(stack, (EntityPlayer) entity);
return true;
}
static void chargeFromArmor (ItemStack stack, EntityPlayer player)
{
boolean inContainer = false;
for (int armorIter = 0; armorIter < 4; ++armorIter)
{
ItemStack armor = player.inventory.armorInventory[armorIter];
if (armor != null && armor.getItem() instanceof IElectricItem)
{
IElectricItem electricArmor = (IElectricItem) armor.getItem();
ToolCore tool = (ToolCore) stack.getItem();
if (electricArmor.canProvideEnergy() && electricArmor.getTier() >= ((IElectricItem) stack.getItem()).getTier())
{
int chargeAmount = tool.charge(stack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true);
chargeAmount = discharge(armor, chargeAmount, Integer.MAX_VALUE, true, false);
if (chargeAmount > 0)
{
tool.charge(stack, chargeAmount, Integer.MAX_VALUE, true, false);
inContainer = true;
}
}
}
}
if (inContainer)
{
player.openContainer.detectAndSendChanges();
}
}
public static int discharge (ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{
IElectricItem ielectricitem = (IElectricItem) itemStack.getItem();
if (ielectricitem instanceof ICustomElectricItem)
{
return ((ICustomElectricItem) ielectricitem).discharge(itemStack, amount, tier, ignoreTransferLimit, simulate);
}
else if (amount >= 0 && itemStack.stackSize <= 1 && ielectricitem.getTier() <= tier)
{
if (amount > ielectricitem.getTransferLimit() && !ignoreTransferLimit)
{
amount = ielectricitem.getTransferLimit();
}
NBTTagCompound tags = StackUtil.getOrCreateNbtData(itemStack);
int charge = tags.getInteger("charge");
if (amount > charge)
{
amount = charge;
}
charge -= amount;
if (!simulate)
{
tags.setInteger("charge", charge);
itemStack.itemID = charge > 0 ? ielectricitem.getChargedItemId() : ielectricitem.getEmptyItemId();
if (itemStack.getItem() instanceof IElectricItem)
{
ielectricitem = (IElectricItem) itemStack.getItem();
if (itemStack.getMaxDamage() > 2)
{
itemStack.setItemDamage(1 + (ielectricitem.getMaxCharge() - charge) * (itemStack.getMaxDamage() - 2) / ielectricitem.getMaxCharge());
}
else
{
itemStack.setItemDamage(0);
}
}
else
{
itemStack.setItemDamage(0);
}
}
return amount;
}
else
{
return 0;
}
}
public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity player)
{
tags.getCompoundTag("InfiTool").setBoolean("Broken", true);
player.worldObj.playSound(player.posX, player.posY, player.posZ, "random.break", 1f, 1f, true);
}
public static void repairTool (ItemStack stack, NBTTagCompound tags)
{
tags.getCompoundTag("InfiTool").setBoolean("Broken", false);
tags.getCompoundTag("InfiTool").setInteger("Damage", 0);
}
/* Entities */
public static void hitEntity (ItemStack stack, EntityLiving mob, EntityLiving player)
{
hitEntity(stack, mob, player, 1f);
}
public static void hitEntity (ItemStack stack, EntityLiving mob, EntityLiving player, float bonusDamage)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").getBoolean("Broken"))
{
int durability = tags.getCompoundTag("InfiTool").getInteger("Damage");
float shoddy = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
float damageModifier = -shoddy * durability / 100f;
int attack = (int) ((tags.getCompoundTag("InfiTool").getInteger("Attack") + damageModifier) * bonusDamage);
if (player instanceof EntityPlayer)
mob.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), attack);
else
mob.attackEntityFrom(DamageSource.causeMobDamage(player), attack);
}
if (mob.hurtResistantTime <= 0)
damageTool(stack, 1, tags, player);
}
public static DamageSource causePiercingDamage (EntityLiving mob)
{
return new PiercingEntityDamage("mob", mob);
}
public static DamageSource causePlayerPiercingDamage (EntityPlayer player)
{
return new PiercingEntityDamage("player", player);
}
public static void thrust (ItemStack stack, World world, EntityPlayer player)
{
if (mc == null)
mc = FMLClientHandler.instance().getClient();
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY)
{
mc.playerController.attackEntity(player, mc.objectMouseOver.entityHit);
mc.playerController.attackEntity(player, mc.objectMouseOver.entityHit);
mc.playerController.attackEntity(player, mc.objectMouseOver.entityHit);
}
}
public static void knockbackEntity (EntityLiving living, double boost)
{
living.motionX *= boost;
//living.motionY *= boost/2;
living.motionZ *= boost;
}
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
if (!player.canPlayerEdit(x, y, z, side, stack))
{
return false;
}
else
{
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
onBlockChanged(stack, world, 0, x, y, z, player, random);
return true;
}
int bID = world.getBlockId(x, y, z);
int bIDabove = world.getBlockId(x, y + 1, z);
if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID)
{
return false;
}
else
{
Block block = Block.tilledField;
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if (world.isRemote)
{
return true;
}
else
{
world.setBlockWithNotify(x, y, z, block.blockID);
onBlockChanged(stack, world, 0, x, y, z, player, random);
return true;
}
}
}
}
}
+153
View File
@@ -0,0 +1,153 @@
package tinker.tconstruct;
/**
* This class is temporary. A full material registry is planned
*/
public enum EnumMaterial
{
Wood(0, 59, 200, 0, 1.0F, 0, 0),
Stone(1, 131, 400, 1, 0.5F, 0, 1f),
Iron(2, 250, 600, 2, 1.3F, 1, 0),
Flint(1, 171, 525, 2, 0.7F, 0, 1f),
Cactus(1, 150, 500, 2, 1.0F, 0, -1f),
Obsidian(3, 89, 800, 2, 0.8F, 5, 0),
Bone(1, 200, 500, 2, 1.0F, 0, 0),
Netherrack(2, 131, 400, 1, 1.2F, 0, 1f),
Slime(3, 1500, 150, 0, 5.0F, 0, 0),
Paper(0, 131, 200, 0, 0.1F, 0, 0),
Cobalt(4, 800, 800, 3, 1.8F, 2, 0),
Ardite(4, 800, 800, 3, 1.8F, 0, 0),
Manyullyn(5, 1200, 1200, 4, 2.5F, 0, 0),
Demonite(5, 1790, 900, 5, 1.66F, 0, 0),
Holyshell(5, 1000, 700, 1, 1.5F, 0, 0);
//mining level, durability, mining speed, baseDamage, handle modifier, Durability level, shoddy level, spiny level
private final int harvestLevel;
private final int durability;
private final int miningspeed; // <-- divided by 100
private final int damageVsEntity;
private final float handleDurability;
private final int unbreaking;
private final float shoddy;
private EnumMaterial(int level, int dur, int speed, int damage, float handle, int unb, float shd)
{
this.harvestLevel = level;
this.durability = dur;
this.miningspeed = speed;
this.damageVsEntity = damage;
this.handleDurability = handle;
this.unbreaking = unb;
this.shoddy = shd;
}
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
public int durability()
{
return this.durability;
}
public static int durability(int type)
{
return getEnumByType(type).durability();
}
/**
* The strength of this tool material against blocks which it is effective against.
*/
public int toolSpeed()
{
return this.miningspeed;
}
public static int toolSpeed(int type)
{
return getEnumByType(type).toolSpeed();
}
/**
* Damage versus entities.
*/
public int attack()
{
return this.damageVsEntity;
}
public static int attack(int type)
{
return getEnumByType(type).attack();
}
/*
* Harvest level of the tool
*/
public int harvestLevel()
{
return this.harvestLevel;
}
public static int harvestLevel(int type)
{
return getEnumByType(type).harvestLevel();
}
/*
* Durability modifier of the handle
*/
public float handleDurability()
{
return this.handleDurability;
}
public static float handleDurability(int type)
{
return getEnumByType(type).handleDurability();
}
public int unbreaking()
{
return this.unbreaking;
}
public static int unbreaking(int type)
{
return getEnumByType(type).unbreaking();
}
public float shoddy()
{
return this.shoddy;
}
public static float shoddy(int type)
{
return getEnumByType(type).shoddy();
}
static EnumMaterial getEnumByType(int type)
{
switch (type)
{
case 0: return Wood;
case 1: return Stone;
case 2: return Iron;
case 3: return Flint;
case 4: return Cactus;
case 5: return Obsidian;
case 6: return Bone;
case 7: return Netherrack;
case 8: return Slime;
case 9: return Paper;
case 10: return Cobalt;
case 11: return Ardite;
case 12: return Manyullyn;
case 13: return Demonite;
case 14: return Holyshell;
}
return null;
}
}
+48
View File
@@ -0,0 +1,48 @@
package tinker.tconstruct;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import tinker.common.InventoryLogic;
import tinker.tconstruct.client.gui.FrypanGui;
import tinker.tconstruct.client.gui.PartCrafterGui;
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;
public class GuiHandler implements IGuiHandler
{
int stationID = 0;
int partID = 1;
int pchestID = 2;
int smeltery = 3;
int frypanID = 4;
@Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile != null && tile instanceof InventoryLogic)
return ((InventoryLogic) tile).getGuiContainer(player.inventory, world, x, y, z);
return null;
}
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
if (ID == stationID)
return new ToolStationGui(player.inventory, (ToolStationLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == partID)
return new PartCrafterGui(player.inventory, (PartCrafterLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == pchestID)
return new PatternChestGui(player.inventory, (PatternChestLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
if (ID == frypanID)
return new FrypanGui(player.inventory, (FrypanLogic) world.getBlockTileEntity(x, y, z), world, x, y, z);
return null;
}
}
+144
View File
@@ -0,0 +1,144 @@
package tinker.tconstruct;
import java.io.File;
import java.io.IOException;
import net.minecraftforge.common.Configuration;
public class PHConstruct {
public static void initProps()
{
/* Here we will set up the config file for the mod
* First: Create a folder inside the config folder
* Second: Create the actual config file
* Note: Configs are a pain, but absolutely necessary for every mod.
*/
File file = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop");
file.mkdir();
File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop/TConstruct.txt");
/* Some basic debugging will go a long way */
try
{
newFile.createNewFile();
}
catch (IOException e)
{
System.out.println("Could not create configuration file for TConstruct. Reason:");
System.out.println(e);
}
/* [Forge] Configuration class, used as config method */
Configuration config = new Configuration(newFile);
/* Load the configuration file */
config.load();
/* Define the mod's IDs.
* Avoid values below 4096 for items and in the 250-450 range for blocks
*/
woodCrafter = config.getBlock("Wood Tool Station", 1471).getInt(1471);
heldItemBlock = config.getBlock("Held Item Block", 1472).getInt(1472);
lavaTank = config.getBlock("Lava Tank", 1473).getInt(1473);
smeltery = config.getBlock("Smeltery", 1474).getInt(1474);
ores = config.getBlock("Ore Block", 1475).getInt(1475);
craftedSoil = config.getBlock("Special Soil", 1476).getInt(1476);
searedBrick = config.getBlock("Seared Brick", 1477).getInt(1477);
materials = config.getItem("Patterns and Misc", "Materials", 14020).getInt(14020);
toolRod = config.getItem("Patterns and Misc", "Tool Rod", 14021).getInt(14021);
toolShard = config.getItem("Patterns and Misc", "Tool Shard", 14022).getInt(14022);
woodPattern = config.getItem("Patterns and Misc", "Wood Pattern", 14023).getInt(14023);
//stonePattern = config.getItem("Patterns and Misc", "Stone Pattern", 14024).getInt(14024);
//netherPattern = config.getItem("Patterns and Misc", "Nether Pattern", 14025).getInt(14025);
pickaxeHead = config.getItem("Tool Parts", "Pickaxe Head", 14026).getInt(14026);
shovelHead = config.getItem("Tool Parts", "Shovel Head", 14027).getInt(14027);
axeHead = config.getItem("Tool Parts", "Axe Head", 14028).getInt(14028);
hoeHead = config.getItem("Tool Parts", "Hoe Head", 14029).getInt(14029);
swordBlade = config.getItem("Tool Parts", "Sword Blade", 14030).getInt(14030);
largeGuard = config.getItem("Tool Parts", "Large Guard", 14031).getInt(14031);
medGuard = config.getItem("Tool Parts", "Medium Guard", 14032).getInt(14032);
crossbar = config.getItem("Tool Parts", "Crossbar", 14033).getInt(14033);
binding = config.getItem("Tool Parts", "Tool Binding", 14034).getInt(14034);
frypanHead = config.getItem("Tool Parts", "Frypan Head", 14035).getInt(14035);
signHead = config.getItem("Tool Parts", "Sign Head", 14036).getInt(14036);
lumberHead = config.getItem("Tool Parts", "Lumber Axe Head", 14036).getInt(14036);
pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051);
shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052);
axe = config.getItem("Tools", "Axe", 14053).getInt(14053);
hoe = config.getItem("Tools", "Hoe", 14054).getInt(14054);
broadsword = config.getItem("Tools", "Broadsword", 14055).getInt(14055);
longsword = config.getItem("Tools", "Longsword", 14056).getInt(14056);
rapier = config.getItem("Tools", "Rapier", 14057).getInt(14057);
frypan = config.getItem("Tools", "Frying Pan", 14058).getInt(14058);
battlesign = config.getItem("Tools", "Battlesign", 14059).getInt(14059);
mattock = config.getItem("Tools", "Mattock", 14060).getInt(14060);
lumberaxe = config.getItem("Tools", "Lumber Axe", 14061).getInt(14061);
/* Save the configuration file */
config.save();
}
//Blocks
public static int woodCrafter;
public static int stoneCrafter;
public static int netherCrafter;
public static int heldItemBlock;
public static int ores;
public static int lavaTank;
public static int smeltery;
public static int craftedSoil;
public static int searedBrick;
//Patterns and misc
public static int materials;
public static int toolRod;
public static int toolShard;
public static int woodPattern;
//public static int stonePattern;
//public static int netherPattern;
//Tools
public static int pickaxe;
public static int shovel;
public static int axe;
public static int hoe;
public static int broadsword;
public static int longsword;
public static int rapier;
public static int frypan;
public static int battlesign;
public static int mattock;
public static int lumberaxe;
//Tool parts
public static int swordBlade;
public static int largeGuard;
public static int medGuard;
public static int crossbar;
public static int pickaxeHead;
public static int axeHead;
public static int shovelHead;
public static int hoeHead;
public static int frypanHead;
public static int signHead;
public static int lumberHead;
public static int binding;
}
@@ -0,0 +1,16 @@
package tinker.tconstruct;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.StatCollector;
public class PiercingEntityDamage extends EntityDamageSource
{
public PiercingEntityDamage(String str, Entity entity)
{
super(str, entity);
this.setDamageBypassesArmor();
}
}
+155
View File
@@ -0,0 +1,155 @@
package tinker.tconstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import tinker.tconstruct.client.gui.ToolGuiElement;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
/** TConstruct, the successor to InfiTools
* Now with many much more combinations and many much less IDs!
* @author: mDiyo
*/
@Mod(modid = "TConstruct", name = "TConstruct", version = "A16")
@NetworkMod(serverSideRequired = false, clientSideRequired = true)
public class TConstruct
{
/* Instance of this mod, used for grabbing prototype fields */
@Instance("TConstruct")
public static TConstruct instance;
/* Proxies for sides, used for graphics processing */
@SidedProxy(clientSide = "tinker.tconstruct.client.TProxyClient", serverSide = "tinker.tconstruct.TProxyCommon")
public static TProxyCommon proxy;
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<ToolGuiElement>(30);
@PreInit
public void preInit(FMLPreInitializationEvent evt)
{
MinecraftForge.EVENT_BUS.register(this);
PHConstruct.initProps();
materialTab = new TabTools("TConMaterials");
toolTab = new TabTools("TConstruct");
blockTab = new TabTools("TConstructBlocks");
content = new TConstructContent();
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
addToolButtons();
}
@Init
public void load(FMLInitializationEvent evt)
{
proxy.registerRenderer();
proxy.addNames();
//GameRegistry.registerWorldGenerator(new TBaseWorldGenerator());
}
@ForgeSubscribe
public void registerOre(OreRegisterEvent evt)
{
if (evt.Name == "battery")
content.modE.batteries.add(evt.Ore);
if (evt.Name == "basicCircuit")
content.modE.circuits.add(evt.Ore);
}
static int[][] slotTypes = {
new int[] {0, 3, 0}, //Repair
new int[] {1, 4, 0}, //Pickaxe
new int[] {2, 5, 0}, //Shovel
new int[] {2, 6, 0}, //Axe
new int[] {2, 9, 0}, //Lumber Axe
new int[] {1, 7, 0}, //Ice Axe
new int[] {3, 8, 0}, //Mattock
new int[] {1, 0, 1}, //Broadsword
new int[] {1, 1, 1}, //Longsword
new int[] {1, 2, 1}, //Rapier
new int[] {2, 3, 1}, //Frying pan
new int[] {2, 4, 1} //Battlesign
};
static int[][] iconCoords = {
new int[] { 0, 1, 2 }, new int[] { 13, 13, 13 }, //Repair
new int[] { 0, 0, 1 }, new int[] { 2, 3, 3 }, //Pickaxe
new int[] { 3, 0, 13 }, new int[] { 2, 3, 13 }, //Shovel
new int[] { 2, 0, 13 }, new int[] { 2, 3, 13 }, //Axe
new int[] { 6, 0, 13 }, new int[] { 2, 3, 13 }, //Lumber Axe
new int[] { 0, 0, 5 }, new int[] { 2, 3, 3 }, //Ice Axe
new int[] { 2, 0, 3 }, new int[] { 2, 3, 2 }, //Mattock
new int[] { 1, 0, 2 }, new int[] { 2, 3, 3 }, //Broadsword
new int[] { 1, 0, 3 }, new int[] { 2, 3, 3 }, //Longsword
new int[] { 1, 0, 4 }, new int[] { 2, 3, 3 }, //Rapier
new int[] { 4, 0, 13 }, new int[] { 2, 3, 13 }, //Frying Pan
new int[] { 5, 0, 13 }, new int[] { 2, 3, 13 } //Battlesign
};
static String[] toolNames = {
"Repair and Modification",
"Pickaxe",
"Shovel",
"Axe",
"Lumber Axe",
"Ice Axe",
"Mattock",
"Broadsword",
"Longsword",
"Rapier",
"Frying Pan",
"Battlesign"
};
static String[] toolDescriptions = {
"The main way to repair or change your tools. Place a tool and a material on the left to get started.",
"The Pickaxe is a basic mining tool. It is effective on stone and ores.\n\nRequired parts:\n- Pickaxe Head\n- Tool Binding\n- Handle",
"The Shovel is a basic digging tool. It is effective on dirt and sand.\n\nRequired parts:\n- Shovel Head\n- Handle",
"The Axe is a basic chopping tool. It is effective on wood and leaves.\n\nRequired parts:\n- Axe Head\n- Handle",
"The Lumber Axe is a broad chopping tool. It harvests wood in a wide range and can fell entire trees.\n\nRequired parts:\n- Broad Axe Head\n- Handle",
"The Ice Axe is a tool for harvesting ice, mining, and attacking foes.\n\nSpecial Ability:\n- Wall Climb\nNatural Ability:\n- Ice Harvest\nDamage: Moderate\n\nRequired parts:\n- Pickaxe Head\n- Spike\n- Handle",
"The Cutter Mattock is a multi-use tool. It is effective on wood, leaves, dirt, and sand.\n\nSpecial Ability: Hoe\n\nRequired parts:\n- Axe Head\n- Shovel Head\n- Handle",
"The Broadsword is a defensive weapon. Blocking cuts damage in half.\n\nSpecial Ability: Block\nDamage: Moderate\nDurability: High\n\nRequired parts:\n- Sword Blade\n- Large Guard\n- Handle",
"The Longsword is a balanced weapon. It is useful for knocking enemies away or getting in and out of battle quickly.\n\nSpecial Ability: Lunge\nDamage: Moderate\nDurability: Moderate\n\nRequired parts:\n- Sword Blade\n- Medium Guard\n- Handle",
"The Rapier is an offensive weapon that relies on quick strikes to defeat foes.\n\nNatural Abilities:\n- Armor Pierce\n- Quick Strike\nDamage: High\nDurability: Low\n\nRequired parts:\n- Sword Blade\n- Crossbar\n- Handle",
"The Frying is a heavy weapon that uses sheer weight to stun foes.\n\nSpecial Ability: Block\nNatural Ability: Bash\nShift+rClick: Place Frying Pan\nDamage: High\nDurability: High\n\nRequired parts:\n- Pan\n- Handle",
"The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\nSpecial Ability: Block\nShift-rClick: Place sign\nDamage: Low\nDurability: Average\n\nRequired parts:\n- Board\n- Handle"
};
void addToolButtons()
{
for (int i = 0; i < toolNames.length; i++)
{
addToolButton(slotTypes[i][0], slotTypes[i][1], slotTypes[i][2], iconCoords[i*2], iconCoords[i*2+1], toolNames[i], toolDescriptions[i]);
}
}
private void addToolButton(int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body)
{
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body));
}
public static void addToolButton(int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String texture)
{
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, texture));
}
TConstructContent content;
public static Random tRand = new Random();
public static TabTools toolTab;
public static TabTools materialTab;
public static TabTools blockTab;
}
+292
View File
@@ -0,0 +1,292 @@
package tinker.tconstruct;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.ShapedOreRecipe;
import tinker.tconstruct.blocks.EquipBlock;
import tinker.tconstruct.blocks.LavaTankBlock;
import tinker.tconstruct.blocks.SmelteryBlock;
import tinker.tconstruct.blocks.TConstructBlock;
import tinker.tconstruct.blocks.ToolStationBlock;
import tinker.tconstruct.crafting.PatternBuilder;
import tinker.tconstruct.crafting.ToolBuilder;
import tinker.tconstruct.items.Materials;
import tinker.tconstruct.items.Pattern;
import tinker.tconstruct.items.ToolPart;
import tinker.tconstruct.modifiers.ModDurability;
import tinker.tconstruct.modifiers.ModElectric;
import tinker.tconstruct.modifiers.ModLapisBase;
import tinker.tconstruct.modifiers.ModLapisIncrease;
import tinker.tconstruct.modifiers.ModRedstone;
import tinker.tconstruct.modifiers.ModRepair;
import tinker.tconstruct.tools.Axe;
import tinker.tconstruct.tools.BattleSign;
import tinker.tconstruct.tools.Broadsword;
import tinker.tconstruct.tools.FryingPan;
import tinker.tconstruct.tools.Longsword;
import tinker.tconstruct.tools.LumberAxe;
import tinker.tconstruct.tools.Mattock;
import tinker.tconstruct.tools.Pickaxe;
import tinker.tconstruct.tools.Rapier;
import tinker.tconstruct.tools.Shovel;
import tinker.tconstruct.tools.ToolCore;
import cpw.mods.fml.common.registry.GameRegistry;
public class TConstructContent
{
//Patterns and other materials
public static Item materials;
public static Item toolRod;
public static Item toolShard;
public static Item woodPattern;
//public static Item stonePattern;
//public static Item netherPattern;
//Tools
public static ToolCore pickaxe;
public static ToolCore shovel;
public static ToolCore axe;
public static ToolCore broadsword;
public static ToolCore longsword;
public static ToolCore rapier;
public static ToolCore frypan;
public static ToolCore battlesign;
public static ToolCore mattock;
public static ToolCore lumberaxe;
//Tool parts
public static Item pickaxeHead;
public static Item shovelHead;
public static Item axeHead;
public static Item swordBlade;
public static Item largeGuard;
public static Item medGuard;
public static Item crossbar;
public static Item binding;
public static Item frypanHead;
public static Item signHead;
public static Item lumberHead;
//Crafting blocks
public static Block woodCrafter;
public static Block smeltery;
//public static Block stoneCrafter;
//public static Block netherCrafter;
public static Block heldItemBlock;
public static Block ores;
public static Block lavaTank;
public static Block craftedSoil;
public static Block searedBrick;
//Tool modifiers
public static ModElectric modE;
public TConstructContent()
{
createItems();
registerMaterials();
addToolRecipes();
addCraftingRecipes();
setupToolTabs();
}
void createItems ()
{
woodCrafter = new ToolStationBlock(PHConstruct.woodCrafter, Material.wood);
GameRegistry.registerBlock(woodCrafter, tinker.tconstruct.blocks.ToolStationItemBlock.class, "ToolStationBlock");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.ToolStationLogic.class, "ToolStation");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.PartCrafterLogic.class, "PartCrafter");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.PatternChestLogic.class, "PatternHolder");
heldItemBlock = new EquipBlock(PHConstruct.heldItemBlock, Material.wood);
GameRegistry.registerBlock(heldItemBlock, "HeldItemBlock");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.FrypanLogic.class, "FrypanLogic");
//ores = new TBaseOre(PHTools.ores, 48);
//GameRegistry.registerBlock(ores, tinker.toolconstruct.blocks.TBaseOreItem.class, "TConstruct.ores");
lavaTank = new LavaTankBlock(PHConstruct.lavaTank);
GameRegistry.registerBlock(lavaTank, "LavaTank");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.LavaTankLogic.class, "TConstruct.LavaTank");
smeltery = new SmelteryBlock(PHConstruct.smeltery);
GameRegistry.registerBlock(smeltery, "Smeltery");
GameRegistry.registerTileEntity(tinker.tconstruct.logic.SmelteryLogic.class, "TConstruct.Smeltery");
craftedSoil = new TConstructBlock(PHConstruct.craftedSoil, 96, Material.sand, 3.0F);
craftedSoil.stepSound = Block.soundGravelFootstep;
GameRegistry.registerBlock(craftedSoil, tinker.tconstruct.blocks.CraftedSoilItemBlock.class, "CraftedSoil");
searedBrick = new TConstructBlock(PHConstruct.searedBrick, 80, Material.iron, 10.0F);
GameRegistry.registerBlock(searedBrick, tinker.tconstruct.blocks.SearedBrickItemBlock.class, "SearedBrick");
MinecraftForge.setBlockHarvestLevel(searedBrick, 0, "pickaxe", 2);
materials = new Materials(PHConstruct.materials, 64, craftingTexture).setItemName("tconstruct.Materials");
toolRod = new ToolPart(PHConstruct.toolRod, 0, craftingTexture).setItemName("tconstruct.ToolRod");
toolShard = new ToolPart(PHConstruct.toolShard, 64, craftingTexture).setItemName("tconstruct.ToolShard");
woodPattern = new Pattern(PHConstruct.woodPattern, 0, patternTexture).setItemName("tconstruct.Pattern");
//stonePattern = new Pattern(PHTools.stonePattern, 64, patternTexture).setItemName("tconstruct.Pattern");
//netherPattern = new Pattern(PHTools.netherPattern, 128, patternTexture).setItemName("tconstruct.Pattern");
pickaxe = new Pickaxe(PHConstruct.pickaxe, pickaxeTexture);
shovel = new Shovel(PHConstruct.shovel, shovelTexture);
axe = new Axe(PHConstruct.axe, axeTexture);
broadsword = new Broadsword(PHConstruct.broadsword, broadswordTexture);
longsword = new Longsword(PHConstruct.longsword, longswordTexture);
rapier = new Rapier(PHConstruct.rapier, rapierTexture);
frypan = new FryingPan(PHConstruct.frypan, frypanTexture);
battlesign = new BattleSign(PHConstruct.battlesign, signTexture);
mattock = new Mattock(PHConstruct.mattock, mattockTexture);
lumberaxe = new LumberAxe(PHConstruct.lumberaxe, lumberaxeTexture);
pickaxeHead = new ToolPart(PHConstruct.pickaxeHead, 0, baseHeads).setItemName("tconstruct.PickaxeHead");
shovelHead = new ToolPart(PHConstruct.shovelHead, 64, baseHeads).setItemName("tconstruct.ShovelHead");
axeHead = new ToolPart(PHConstruct.axeHead, 128, baseHeads).setItemName("tconstruct.AxeHead");
swordBlade = new ToolPart(PHConstruct.swordBlade, 0, swordparts).setItemName("tconstruct.SwordBlade");
largeGuard = new ToolPart(PHConstruct.largeGuard, 64, swordparts).setItemName("tconstruct.LargeGuard");
medGuard = new ToolPart(PHConstruct.medGuard, 128, swordparts).setItemName("tconstruct.MediumGuard");
crossbar = new ToolPart(PHConstruct.crossbar, 192, swordparts).setItemName("tconstruct.Crossbar");
binding = new ToolPart(PHConstruct.binding, 0, baseAccessories).setItemName("tconstruct.Binding");
frypanHead = new ToolPart(PHConstruct.frypanHead, 0, jokeparts).setItemName("tconstruct.FrypanHead");
signHead = new ToolPart(PHConstruct.signHead, 64, jokeparts).setItemName("tconstruct.SignHead");
lumberHead = new ToolPart(PHConstruct.lumberHead, 0, broadheads).setItemName("tconstruct.LumberHead");
}
void registerMaterials ()
{
PatternBuilder pb = PatternBuilder.instance;
pb.registerFullMaterial(Block.planks, 2, "wood", new ItemStack(Item.stick), new ItemStack(Item.stick), 0);
pb.registerFullMaterial(Block.stone, 2, "stone", 1);
pb.registerMaterial(Block.cobblestone, 2, "stone");
pb.registerFullMaterial(Item.ingotIron, 2, "iron", 2);
pb.registerFullMaterial(Item.flint, 2, "flint", 3);
pb.registerFullMaterial(Block.cactus, 2, "cactus", 4);
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.netherrack, 2, "netherrack", 7);
pb.registerFullMaterial(Item.slimeBall, 2, "slime", 8); //TODO: Register a better material
pb.registerFullMaterial(Item.paper, 2, "paper", new ItemStack(Item.paper), new ItemStack(toolRod, 1, 9), 9); //TODO: Register a better material
Item[] items = { toolRod, pickaxeHead, shovelHead, axeHead, swordBlade, largeGuard, medGuard, crossbar, binding, frypanHead, signHead, lumberHead };
for (int iter = 0; iter < items.length; iter++)
{
pb.addToolPattern(new ItemStack(woodPattern, 1, iter+1), items[iter]);
//pb.addToolPattern(new ItemStack(stonePattern, 1, iter+1), items[iter]);
//pb.addToolPattern(new ItemStack(netherPattern, 1, iter+1), items[iter]);
}
}
void addToolRecipes ()
{
ToolBuilder tb = ToolBuilder.instance;
tb.addToolRecipe(pickaxe, pickaxeHead, binding);
tb.addToolRecipe(broadsword, swordBlade, largeGuard);
tb.addToolRecipe(axe, axeHead);
tb.addToolRecipe(shovel, shovelHead);
tb.addToolRecipe(longsword, swordBlade, medGuard);
tb.addToolRecipe(rapier, swordBlade, crossbar);
tb.addToolRecipe(frypan, frypanHead);
tb.addToolRecipe(battlesign, signHead);
tb.addToolRecipe(mattock, axeHead, shovelHead);
tb.addToolRecipe(lumberaxe, lumberHead);
tb.registerToolMod(new ModRepair());
tb.registerToolMod(new ModDurability(new ItemStack[] {new ItemStack(Item.diamond)}, 0, 500, 0f, 3, "Diamond", "\u00a7bDurability +500", "\u00a7b"));
tb.registerToolMod(new ModDurability(new ItemStack[] {new ItemStack(Item.emerald)}, 1, 0, 0.5f, 2, "Emerald", "\u00a72Durability +50%", "\u00a72"));
modE = new ModElectric();
tb.registerToolMod(modE);
tb.registerToolMod(new ModRedstone(new ItemStack[] {new ItemStack(Item.redstone)}, 2, 1));
tb.registerToolMod(new ModRedstone(new ItemStack[] { new ItemStack(Item.redstone), new ItemStack(Item.redstone) }, 2, 2));
tb.registerToolMod(new ModLapisBase(new ItemStack[] {new ItemStack(Block.blockLapis), new ItemStack(Block.blockLapis)}, 10));
tb.registerToolMod(new ModLapisIncrease(new ItemStack[] {new ItemStack(Item.dyePowder, 1, 4)}, 10, 1));
tb.registerToolMod(new ModLapisIncrease(new ItemStack[] {new ItemStack(Block.blockLapis)}, 10, 9));
ItemStack reBattery = ic2.api.Items.getItem("reBattery");
if (reBattery != null)
modE.batteries.add(reBattery);
ItemStack chargedReBattery = ic2.api.Items.getItem("chargedReBattery");
if (chargedReBattery != null)
modE.batteries.add(chargedReBattery);
ItemStack electronicCircuit = ic2.api.Items.getItem("electronicCircuit");
if (electronicCircuit != null)
modE.circuits.add(electronicCircuit);
}
void addCraftingRecipes ()
{
/*GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 0), "c", 'c', Block.workbench);
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 1), "cc", 'c', Block.workbench);*/
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 0), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', Block.workbench);
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 1), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 0));
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 2), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 1));
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 3), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 2));
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 4), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 3));
GameRegistry.addRecipe(new ItemStack(woodCrafter, 1, 5), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', Block.chest);
GameRegistry.addRecipe( new ShapedOreRecipe(new ItemStack(woodCrafter, 1, 1), "p", "w", 'p', new ItemStack(woodPattern, 1, 0), 'w', "logWood"));
GameRegistry.addRecipe( new ShapedOreRecipe(new ItemStack(woodPattern, 1, 0), "ps", "sp", 'p', "plankWood", 's', Item.stick));
/*GameRegistry.addRecipe(new ItemStack(stonePattern, 1, 0), "ps", "sp", 'p', Block.cobblestone, '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));*/
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.stonePattern, 1, i + 1), "s", 's', new ItemStack(TConstructContent.stonePattern, 1, i));
GameRegistry.addRecipe(new ItemStack(TConstructContent.netherPattern, 1, i + 1), "s", 's', new ItemStack(TConstructContent.netherPattern, 1, i));*/
}
}
void setupToolTabs ()
{
TConstruct.materialTab.init(new ItemStack(TConstructContent.woodPattern, 1, 255));
TConstruct.blockTab.init(new ItemStack(woodCrafter));
ItemStack tool = new ItemStack(longsword, 1, 0);
NBTTagCompound compound = new NBTTagCompound();
compound.setCompoundTag("InfiTool", new NBTTagCompound());
compound.getCompoundTag("InfiTool").setInteger("RenderHead", 2);
compound.getCompoundTag("InfiTool").setInteger("RenderHandle", 0);
compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", 10);
tool.setTagCompound(compound);
TConstruct.toolTab.init(tool);
}
ItemStack[] materialArray = { new ItemStack(Block.planks), new ItemStack(Block.cobblestone), new ItemStack(Item.ingotIron), new ItemStack(Item.flint),
new ItemStack(Block.cactus), new ItemStack(Item.bone), new ItemStack(Block.obsidian), new ItemStack(Block.netherrack), new ItemStack(Item.slimeBall),
new ItemStack(Item.paper) };
public static String blockTexture = "/tinkertextures/ConstructBlocks.png";
public static String craftingTexture = "/tinkertextures/materials.png";
public static String patternTexture = "/tinkertextures/tools/patterns.png";
public static String baseHeads = "/tinkertextures/tools/baseheads.png";
public static String baseAccessories = "/tinkertextures/tools/baseaccessories.png";
public static String swordparts = "/tinkertextures/tools/swordparts.png";
public static String jokeparts = "/tinkertextures/tools/jokeparts.png";
public static String broadheads = "/tinkertextures/tools/broadheads.png";
public static String pickaxeTexture = "/tinkertextures/tools/pickaxes.png";
public static String broadswordTexture = "/tinkertextures/tools/swordbroad.png";
public static String shovelTexture = "/tinkertextures/tools/shovels.png";
public static String axeTexture = "/tinkertextures/tools/axes.png";
public static String longswordTexture = "/tinkertextures/tools/swordlong.png";
public static String rapierTexture = "/tinkertextures/tools/swordrapier.png";
public static String frypanTexture = "/tinkertextures/tools/frypans.png";
public static String signTexture = "/tinkertextures/tools/battlesigns.png";
public static String mattockTexture = "/tinkertextures/tools/mattock.png";
public static String lumberaxeTexture = "/tinkertextures/tools/lumberaxe.png";
}
+21
View File
@@ -0,0 +1,21 @@
package tinker.tconstruct;
import java.io.File;
/**
* Common proxy class for InfiTools
*/
public class TProxyCommon
{
/* Registers any rendering code. Does nothing server-side */
public void registerRenderer() {}
/* Ties an internal name to a visible one. Does nothing server-side */
public void addNames() {}
public File getLocation()
{
return new File(".");
}
}
+28
View File
@@ -0,0 +1,28 @@
package tinker.tconstruct;
import tinker.tconstruct.crafting.ToolBuilder;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TabTools extends CreativeTabs
{
ItemStack display;
public TabTools(String label)
{
super(label);
}
public void init(ItemStack stack)
{
display = stack;
}
public ItemStack getIconItemStack()
{
return display;
}
}
@@ -0,0 +1,29 @@
package tinker.tconstruct.blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class CraftedSoilItemBlock extends ItemBlock
{
public static final String blockType[] =
{
"Slime", "Grout"
};
public CraftedSoilItemBlock(int id)
{
super(id);
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata(int meta)
{
return meta;
}
public String getItemNameIS(ItemStack itemstack)
{
return (new StringBuilder()).append("CraftedSoil.").append(blockType[itemstack.getItemDamage()]).toString();
}
}
+102
View File
@@ -0,0 +1,102 @@
package tinker.tconstruct.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import tinker.common.InventoryBlock;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.logic.FrypanLogic;
public class EquipBlock extends InventoryBlock
{
public EquipBlock(int id, Material material)
{
super(id, material);
this.setHardness(2f);
this.setBlockBounds(0, 0, 0, 1, 0.25f, 1);
//this.setCreativeTab(ToolConstruct.materialTab);
}
/*public String getTextureFile()
{
return "/tinkertextures/ConstructBlocks.png";
}*/
public int getBlockTextureFromSideAndMetadata (int side, int meta)
{
//return 22 + meta*6 + side;
return 22;
}
@Override
public int idDropped (int par1, Random par2Random, int par3)
{
return 0;
}
public TileEntity createNewTileEntity (World world, int metadata)
{
return new FrypanLogic();
}
/*@Override
public void breakBlock (World par1World, int x, int y, int z, int par5, int par6)
{
EquipLogic logic = (EquipLogic) par1World.getBlockTileEntity(x, y, z);
if (logic != null)
{
ItemStack equip = logic.getEquipmentItem();
if (equip != null)
{
float jumpX = ToolConstruct.tRand.nextFloat() * 0.8F + 0.1F;
float jumpY = ToolConstruct.tRand.nextFloat() * 0.8F + 0.1F;
float jumpZ = ToolConstruct.tRand.nextFloat() * 0.8F + 0.1F;
while (equip.stackSize > 0)
{
int itemSize = ToolConstruct.tRand.nextInt(21) + 10;
if (itemSize > equip.stackSize)
{
itemSize = equip.stackSize;
}
equip.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(equip.itemID, itemSize, equip.getItemDamage()));
if (equip.hasTagCompound())
{
entityitem.func_92014_d().setTagCompound((NBTTagCompound) equip.getTagCompound().copy());
}
float offset = 0.05F;
entityitem.motionX = (double) ((float) ToolConstruct.tRand.nextGaussian() * offset);
entityitem.motionY = (double) ((float) ToolConstruct.tRand.nextGaussian() * offset + 0.2F);
entityitem.motionZ = (double) ((float) ToolConstruct.tRand.nextGaussian() * offset);
par1World.spawnEntityInWorld(entityitem);
}
}
}
super.breakBlock(par1World, x, y, z, par5, par6);
}*/
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
int md = world.getBlockMetadata(x, y, z);
return 3;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
}
+114
View File
@@ -0,0 +1,114 @@
package tinker.tconstruct.blocks;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.client.TankRender;
import tinker.tconstruct.logic.LavaTankLogic;
public class LavaTankBlock extends BlockContainer
{
public LavaTankBlock(int id)
{
super(id, 49, Material.iron);
setCreativeTab(TConstruct.blockTab);
setBlockName("TConstruct.LavaTank");
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
public int getRenderType ()
{
return TankRender.tankModelID;
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
return new LavaTankLogic();
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
{
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(player.getCurrentEquippedItem());
if (liquid != null)
{
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
int amount = logic.fill(0, liquid, true);
if (amount > 0)
return true;
else
return false;
}
else
{
}
return false;
}
@Override
public TileEntity createNewTileEntity (World world)
{
return createNewTileEntity(world, 0);
}
/*public void addCollidingBlockToList (World world, int x, int y, int z, AxisAlignedBB box, List list, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta < 5)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
super.addCollidingBlockToList(world, x, y, z, box, list, entity);
}
if (meta != 2 && meta != 4 && meta != 7 && meta != 9)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, x, y, z, box, list, entity);
}
if (meta != 3 && meta != 4 && meta != 8 && meta != 9)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F);
super.addCollidingBlockToList(world, x, y, z, box, list, entity);
}
if (meta != 3 && meta != 1 && meta != 8 && meta != 6)
{
setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, x, y, z, box, list, entity);
}
if (meta != 1 && meta != 2 && meta != 6 && meta != 7)
{
setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, x, y, z, box, list, entity);
}
setBlockBoundsForItemRender();
}
public void setBlockBoundsForItemRender ()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}*/
}
@@ -0,0 +1,29 @@
package tinker.tconstruct.blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class SearedBrickItemBlock extends ItemBlock
{
public static final String blockType[] =
{
"Brick"
};
public SearedBrickItemBlock(int id)
{
super(id);
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata(int meta)
{
return meta;
}
public String getItemNameIS(ItemStack itemstack)
{
return (new StringBuilder()).append("SearedBrick.").append(blockType[itemstack.getItemDamage()]).toString();
}
}
+171
View File
@@ -0,0 +1,171 @@
package tinker.tconstruct.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tinker.common.IFacingLogic;
import tinker.common.InventoryBlock;
import tinker.common.InventoryLogic;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.logic.SmelteryLogic;
public class SmelteryBlock extends InventoryBlock
{
Random rand;
public SmelteryBlock(int id)
{
super(id, Material.iron);
blockIndexInTexture = 64;
setHardness(1.5F);
setStepSound(soundMetalFootstep);
rand = new Random();
this.setCreativeTab(TConstruct.blockTab);
}
public String getTextureFile ()
{
return TConstructContent.blockTexture;
}
public int getBlockTextureFromSideAndMetadata (int side, int meta)
{
if (side == 0 || side == 1)
{
return blockIndexInTexture + 3 + meta * 4;
}
if (side == 3)
{
return blockIndexInTexture + meta * 4;
}
else
{
return blockIndexInTexture + 2 + meta * 4;
}
}
public int getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
{
InventoryLogic logic = (InventoryLogic) world.getBlockTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getDirection() : 0;
int meta = world.getBlockMetadata(x, y, z);
if (side == 1 || side == 0)
{
return blockIndexInTexture + 3 + meta * 4;
}
if (side == direction)
{
if (isActive(world, x, y, z))
{
return blockIndexInTexture + 1 + meta * 4;
}
else
{
return blockIndexInTexture + meta * 4;
}
}
else
{
return blockIndexInTexture + 2 + meta * 4;
}
}
public int damageDropped (int meta)
{
return meta;
}
public int quantityDropped (Random random)
{
return 1;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return 3;
}
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
if (isActive(world, x, y, z))
{
InventoryLogic logic = (InventoryLogic) world.getBlockTileEntity(x, y, z);
byte face = 0;
if (logic instanceof IFacingLogic)
face = ((IFacingLogic)logic).getDirection();
float f = (float) x + 0.5F;
float f1 = (float) y + 0.0F + (random.nextFloat() * 6F) / 16F;
float f2 = (float) z + 0.5F;
float f3 = 0.52F;
float f4 = random.nextFloat() * 0.6F - 0.3F;
switch (face)
{
case 4:
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
break;
case 5:
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
break;
case 2:
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
break;
case 3:
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
break;
}
}
}
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
return !isActive(world, x, y, z) ? 0 : 7;
}
//@Override
/*public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 9; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}*/
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata)
{
return new SmelteryLogic();
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
super.onBlockPlacedBy(world, x, y, z, entityliving);
onBlockPlacedElsewhere(world, x, y, z, entityliving);
}
public void onBlockPlacedElsewhere(World world, int x, int y, int z, EntityLiving entityliving)
{
SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z);
logic.scanWorld();
}
}
+52
View File
@@ -0,0 +1,52 @@
package tinker.tconstruct.blocks;
import java.util.List;
import java.util.Random;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class TBaseOre extends Block
{
public TBaseOre(int id, int tex)
{
super(id, tex, Material.rock);
enableStats = false;
setCreativeTab(TConstruct.blockTab);
}
public int damageDropped(int meta)
{
return meta;
}
/*@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return TConstructContent.ores.blockID;
}*/
public int getBlockTextureFromSideAndMetadata(int side, int meta)
{
return blockIndexInTexture + meta;
}
public String getTextureFile()
{
return TConstructContent.blockTexture;
}
@Override
public void getSubBlocks(int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 2; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
@@ -0,0 +1,31 @@
package tinker.tconstruct.blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
public class TBaseOreItem extends ItemBlock
{
public static final String blockType[] =
{
"cobalt", "ardite"
};
public TBaseOreItem(int i)
{
super(i);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int md)
{
return md;
}
public String getItemNameIS(ItemStack itemstack)
{
int arrayPos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, 1);
return new StringBuilder().append("block.tconstruct").append(blockType[arrayPos]).toString();
}
}
@@ -0,0 +1,34 @@
package tinker.tconstruct.blocks;
import tinker.tconstruct.TConstructContent;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
public class TConstructBlock extends Block
{
public TConstructBlock(int id, int tex, Material material, float hardness)
{
super(id, tex, material);
setHardness(hardness);
}
@Override
public int damageDropped (int meta)
{
return meta;
}
@Override
public int getBlockTextureFromSideAndMetadata (int side, int meta)
{
return blockIndexInTexture + meta;
}
@Override
public String getTextureFile ()
{
return TConstructContent.blockTexture;
}
}
@@ -0,0 +1,149 @@
package tinker.tconstruct.blocks;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tinker.common.InventoryBlock;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.client.TableRender;
import tinker.tconstruct.logic.PartCrafterLogic;
import tinker.tconstruct.logic.PatternChestLogic;
import tinker.tconstruct.logic.ToolStationLogic;
public class ToolStationBlock extends InventoryBlock
{
public ToolStationBlock(int id, Material material)
{
super(id, material);
this.setCreativeTab(TConstruct.blockTab);
this.setHardness(2f);
}
public String getTextureFile ()
{
return TConstructContent.blockTexture;
}
public int getBlockTextureFromSideAndMetadata (int side, int meta)
{
if (meta == 0)
{
if (side == 0)
return 3;
else if (side == 1)
return 0;
else if (side == 2 || side == 3)
return 1;
else
return 2;
}
else
{
return 1 + meta * 3 + getBlockTextureFromSide(side);
}
}
public int getBlockTextureFromSide (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
return 1;
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
@Override
public int getRenderType ()
{
return TableRender.tabelModelID;
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
public int damageDropped (int meta)
{
return meta;
}
public TileEntity createNewTileEntity (World world, int metadata)
{
switch (metadata)
{
case 0: return new ToolStationLogic();
case 1: return new PartCrafterLogic();
case 2: return new PartCrafterLogic();
case 3: return new PartCrafterLogic();
case 4: return new PartCrafterLogic();
case 5: return new PatternChestLogic();
case 6: return new PatternChestLogic();
case 7: return new PatternChestLogic();
case 8: return new PatternChestLogic();
case 9: return new PatternChestLogic();
case 10: return new PatternChestLogic();
default: return null;
}
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
int md = world.getBlockMetadata(x, y, z);
if (md == 0)
return 0;
else if (md < 5)
return 1;
else if (md < 10)
return 2;
return -1;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, (double) z + this.maxZ);
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
}
}
@@ -0,0 +1,29 @@
package tinker.tconstruct.blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ToolStationItemBlock extends ItemBlock
{
public static final String blockType[] =
{
"Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "Smeltery"
};
public ToolStationItemBlock(int id)
{
super(id);
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata(int meta)
{
return meta;
}
public String getItemNameIS(ItemStack itemstack)
{
return (new StringBuilder()).append("ToolStation.").append(blockType[itemstack.getItemDamage()]).toString();
}
}
+107
View File
@@ -0,0 +1,107 @@
package tinker.tconstruct.client;
import java.io.File;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.MinecraftForgeClient;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.TProxyCommon;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class TProxyClient extends TProxyCommon
{
/* Registers any rendering code. */
public void registerRenderer()
{
RenderingRegistry.registerBlockHandler(new TableRender());
RenderingRegistry.registerBlockHandler(new TankRender());
MinecraftForgeClient.preloadTexture(TConstructContent.craftingTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.baseHeads);
MinecraftForgeClient.preloadTexture(TConstructContent.baseAccessories);
MinecraftForgeClient.preloadTexture(TConstructContent.patternTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.swordparts);
MinecraftForgeClient.preloadTexture(TConstructContent.jokeparts);
MinecraftForgeClient.preloadTexture(TConstructContent.pickaxeTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.broadswordTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.shovelTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.axeTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.longswordTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.rapierTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.frypanTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.signTexture);
MinecraftForgeClient.preloadTexture(TConstructContent.blockTexture);
}
/* Ties an internal name to a visible one. */
public void addNames()
{
LanguageRegistry.addName(TConstructContent.lavaTank, "Lava Tank");
LanguageRegistry.instance().addStringLocalization("itemGroup.TConstruct", "TConstruct Tools");
LanguageRegistry.instance().addStringLocalization("itemGroup.TConMaterials", "TConstruct Materials");
LanguageRegistry.instance().addStringLocalization("crafters.ToolStation", "Tool Station");
LanguageRegistry.instance().addStringLocalization("crafters.PartBuilder", "Part Builder");
LanguageRegistry.instance().addStringLocalization("inventory.PatternChest", "Pattern Chest");
LanguageRegistry.instance().addStringLocalization("crafters.Frypan", "Frying Pan");
LanguageRegistry.instance().addStringLocalization("ToolStation.Crafter.name", "Tool Station");
LanguageRegistry.instance().addStringLocalization("ToolStation.Parts.name", "Part Crafting");
LanguageRegistry.instance().addStringLocalization("ToolStation.PatternChest.name", "Pattern Chest");
for (int mat = 0; mat < materialTypes.length; mat++)
{
for (int type = 0; type < toolMaterialNames.length; type++)
{
String internalName = new StringBuilder().append("item.tconstruct.").append(materialTypes[mat]).append(".").append(toolMaterialNames[type]).append(".name").toString();
String visibleName = new StringBuilder().append(toolMaterialNames[type]).append(materialNames[mat]).toString();
LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName);
}
}
for (int i = 0; i < patterns.length; i++)
{
String internalName = "item.tconstruct.Pattern."+patterns[i]+".name";
String visibleName = patternNames[i]+" Pattern";
LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName);
}
LanguageRegistry.addName(TConstructContent.pickaxe, "Pickaxe");
LanguageRegistry.addName(TConstructContent.shovel, "Shovel");
LanguageRegistry.addName(TConstructContent.axe, "Axe");
LanguageRegistry.addName(TConstructContent.broadsword, "Broadsword");
LanguageRegistry.addName(TConstructContent.longsword, "Longsword");
LanguageRegistry.addName(TConstructContent.rapier, "Rapier");
LanguageRegistry.addName(TConstructContent.frypan, "Frying Pan");
LanguageRegistry.addName(TConstructContent.battlesign, "Battlesign");
LanguageRegistry.addName(TConstructContent.mattock, "Mattock");
LanguageRegistry.addName(TConstructContent.lumberaxe, "Lumber Axe");
}
@Override
public File getLocation()
{
return Minecraft.getMinecraftDir();
}
public static final String[] toolMaterialNames = new String[] {
"Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn" };
public static final String[] materialTypes = new String[] {
"ToolRod", "PickaxeHead", "ToolShard", "ShovelHead", "AxeHead", "SwordBlade", "LargeGuard", "MediumGuard", "Crossbar", "Binding", "FrypanHead", "SignHead", "LumberHead" };
public static final String[] materialNames = new String[] {
" Rod", " Pickaxe Head", " Shard", " Shovel Head", " Axe Head", " Sword Blade", " Wide Guard", " Cover", " Crossbar", " Binding", " Pan", " Board", " Broad Axe Head" };
public static final String[] patterns = new String[] {
"blank", "rod", "pickaxe", "shovel", "axe", "blade", "largeguard", "medguard", "crossbar", "binding", "frypan", "sign", "lumber" };
public static final String[] patternNames = new String[] {
"Blank", "Tool Rod", "Pickaxe Head", "Shovel Head", "Axe Head", "Sword Blade", "Large Guard", "Medium Guard", "Crossbar", "Tool Binding", "Pan", "Board", "Broad Axe Head" };
}
+111
View File
@@ -0,0 +1,111 @@
package tinker.tconstruct.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class TableRender implements ISimpleBlockRenderingHandler
{
public static int tabelModelID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
if (modelID == tabelModelID)
{
if (metadata == 5)
{
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
renderDo(renderer, block, metadata);
}
else
{
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
renderDo(renderer, block, metadata);
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
renderDo(renderer, block, metadata);
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
renderDo(renderer, block, metadata);
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
renderDo(renderer, block, metadata);
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
renderDo(renderer, block, metadata);
}
}
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
if (modelID == tabelModelID)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
{
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
}
else
{
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
}
}
return false;
}
@Override
public boolean shouldRender3DInInventory ()
{
return true;
}
@Override
public int getRenderId ()
{
return tabelModelID;
}
private void renderDo(RenderBlocks renderblocks, Block block, int meta)
{
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F);
renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, meta));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}
+88
View File
@@ -0,0 +1,88 @@
package tinker.tconstruct.client;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import tinker.tconstruct.logic.LavaTankLogic;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class TankRender implements ISimpleBlockRenderingHandler
{
public static int tankModelID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
if (modelID == tankModelID)
{
renderDo(renderer, block, metadata);
}
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
if (modelID == tankModelID)
{
renderer.renderStandardBlock(block, x, y, z);
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
if (logic.amount > 0)
{
Block liquidBlock = Block.blocksList[logic.liquid.itemID];
if (liquidBlock != null)
{
renderer.setRenderBounds(0.03, 0.03, 0.03, 0.97, logic.amount/1020f, 0.97);
renderer.renderStandardBlock(liquidBlock, x, y, z);
}
}
}
return false;
}
@Override
public boolean shouldRender3DInInventory ()
{
return true;
}
@Override
public int getRenderId ()
{
return tankModelID;
}
private void renderDo(RenderBlocks renderblocks, Block block, int meta)
{
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F);
renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, meta));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}
@@ -0,0 +1,126 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.logic.FrypanLogic;
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 FrypanContainer extends Container
{
public FrypanLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public FrypanContainer(InventoryPlayer inventoryplayer, FrypanLogic frypan)
{
logic = frypan;
this.addSlotToContainer(new Slot(frypan, 1, 26, 45));
for (int y = 0; y < 2; y++)
for (int x = 0; x < 4; x++)
this.addSlotToContainer(new Slot(frypan, 2 + x + y*4, 70 + x*18, 27 + 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 i, int j)
{
if (i == 0)
{
logic.progress = j;
}
if (i == 1)
{
logic.fuel = j;
}
if (i == 2)
{
logic.fuelGague = j;
}
}
@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;
}
}
@@ -0,0 +1,44 @@
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.FrypanLogic;
public class FrypanGui extends GuiContainer
{
public FrypanLogic logic;
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z)
{
super(frypan.getGuiContainer(inventoryplayer, world, x, y, z));
logic = frypan;
}
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString(StatCollector.translateToLocal("crafters.Frypan"), 60, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
int texID = mc.renderEngine.getTexture("/tinkertextures/gui/frypan.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.fuel > 0)
{
int fuel = logic.gaugeFuelScaled(12);
drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2);
}
int fuelgague = logic.gaugeProgressScaled(24);
drawTexturedModalRect(cornerX + 140, cornerY + 8, 176, 14, fuelgague, 16);
}
}
@@ -0,0 +1,48 @@
package tinker.tconstruct.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonTool extends GuiButton
{
/**
* True for pointing right (next page), false for pointing left (previous page).
*/
int textureX;
int textureY;
String texture;
public GuiButtonTool(int id, int posX, int posY, int texX, int texY, String tex)
{
super(id, posX, posY, 18, 18, "");
textureX = texX;
textureY = texY;
texture = tex;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
if (this.drawButton)
{
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(mc.renderEngine.getTexture(texture));
this.field_82253_i = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int var5 = this.getHoverState(this.field_82253_i);
int index = 18 * getHoverState(field_82253_i);
//System.out.println("Hover: "+getHoverState(enabled));
this.drawTexturedModalRect(this.xPosition, this.yPosition, index, 0, 18, 18);
this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX*18, textureY*18, 18, 18);
}
}
}
@@ -0,0 +1,62 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.logic.PartCrafterLogic;
import tinker.tconstruct.logic.PatternChestLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class PartCrafterChestContainer extends PartCrafterContainer
{
protected PatternChestLogic patternLogic;
public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartCrafterLogic partLogic, PatternChestLogic pLogic)
{
super (inventoryplayer, partLogic);
patternLogic = pLogic;
largeInventory = true;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new Slot(partLogic, 1, 58, 27), new SlotPattern(partLogic, 2, 40, 45), new Slot(partLogic, 3, 58, 45),
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
for (int iter = 0; iter < inventory.length; iter ++)
this.addSlotToContainer(inventory[iter]);
/* Holder inventory */
for (int column = 0; column < 5; column++)
{
for (int row = 0; row < 6; row++)
{
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, -108 + row * 18, 30 + column * 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 boolean canInteractWith(EntityPlayer var1)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
{
return null;
}
}
@@ -0,0 +1,57 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.logic.PartCrafterLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class PartCrafterContainer extends Container
{
protected InventoryPlayer invPlayer;
protected PartCrafterLogic logic;
protected Slot[] input;
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterContainer(InventoryPlayer inventoryplayer, PartCrafterLogic partLogic)
{
invPlayer = inventoryplayer;
logic = partLogic;
largeInventory = false;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new Slot(partLogic, 1, 58, 27), new SlotPattern(partLogic, 2, 40, 45), new Slot(partLogic, 3, 58, 45),
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
for (int iter = 0; iter < inventory.length; iter ++)
this.addSlotToContainer(inventory[iter]);
/* 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 boolean canInteractWith(EntityPlayer var1)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
{
//TODO: Shift-click override
return null;
}
}
@@ -0,0 +1,91 @@
package tinker.tconstruct.client.gui;
import net.minecraft.client.gui.GuiButton;
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.PartCrafterLogic;
public class PartCrafterGui extends GuiContainer
{
PartCrafterLogic logic;
String title, body = "";
boolean drawChestPart;
public PartCrafterGui(InventoryPlayer inventoryplayer, PartCrafterLogic partlogic, World world, int x, int y, int z)
{
super(partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
logic = partlogic;
drawChestPart = ((PartCrafterContainer)inventorySlots).largeInventory;
title = "\u00A7nTool Part Crafting";
body = "Place a pattern and a material on the left to get started.\n\nDescriptions not done yet, stay tuned.";
}
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), 6, 6, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
if (drawChestPart)
this.fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), -108, this.ySize - 148, 4210752);
drawToolInformation();
}
void drawToolInformation ()
{
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 16777215);
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 16777215);
}
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
// Draw the background
int texID = this.mc.renderEngine.getTexture("/tinkertextures/gui/toolparts.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texID);
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
// Draw Slots
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 0, 166, 98, 36);
if (!logic.isStackInSlot(0))
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(1))
{
this.drawTexturedModalRect(cornerX + 57, cornerY + 26, 176, 18, 18, 18);
}
if (!logic.isStackInSlot(2))
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 44, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(3))
{
this.drawTexturedModalRect(cornerX + 57, cornerY + 44, 176, 36, 18, 18);
}
// Draw chest
if (drawChestPart)
{
texID = this.mc.renderEngine.getTexture("/tinkertextures/gui/patternchestmini.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texID);
this.drawTexturedModalRect(cornerX-116, cornerY+11, 0, 0, this.xSize, this.ySize);
}
// 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);
}
}
@@ -0,0 +1,88 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.logic.PatternChestLogic;
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 PatternChestContainer extends Container
{
public PatternChestLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest)
{
logic = chest;
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 10; row++)
{
this.addSlotToContainer(new Slot(chest, row + column * 10, 8 + row * 18, 18 + column * 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, 17 + row * 18, 86 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144));
}
}
@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;
}
}
@@ -0,0 +1,39 @@
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.PatternChestLogic;
public class PatternChestGui extends GuiContainer
{
public PatternChestLogic logic;
public PatternChestGui(InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z)
{
super(holder.getGuiContainer(inventoryplayer, world, x, y, z));
logic = holder;
xSize = 194;
ySize = 168;
}
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
int texID = mc.renderEngine.getTexture("/tinkertextures/gui/patternchest.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);
}
}
@@ -0,0 +1,24 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.items.Pattern;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotOnlyTake extends Slot
{
public SlotOnlyTake(IInventory builder, int par3, int par4, int par5)
{
super(builder, par3, par4, par5);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack stack)
{
return false;
}
}
@@ -0,0 +1,22 @@
package tinker.tconstruct.client.gui;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tinker.common.IPattern;
public class SlotPattern extends Slot
{
public SlotPattern(IInventory builder, int par3, int par4, int par5)
{
super(builder, par3, par4, par5);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack stack)
{
return stack.getItem() instanceof IPattern;
}
}
@@ -0,0 +1,66 @@
package tinker.tconstruct.client.gui;
import tinker.tconstruct.tools.ToolCore;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class SlotTool extends Slot
{
/** The player that is using the GUI where this slot resides. */
private EntityPlayer player;
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{
super(builder, par3, par4, par5);
this.player = entityplayer;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack stack)
{
return stack.getItem() instanceof ToolCore;
}
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack stack)
{
this.onCrafting(stack);
super.onPickupFromSlot(par1EntityPlayer, stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onCrafting(ItemStack stack, int par2)
{
//this.field_75228_b += par2;
this.onCrafting(stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
*/
protected void onCrafting(ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
for (int i = 1; i <= 3; i++)
inventory.decrStackSize(i, 1);
if (!player.worldObj.isRemote)
player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);
}
}
}
@@ -0,0 +1,37 @@
package tinker.tconstruct.client.gui;
public class ToolGuiElement
{
public final int slotType;
public final int buttonIconX;
public final int buttonIconY;
public final int[] iconsX;
public final int[] iconsY;
public final String title;
public final String body;
public final String texture;
public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b)
{
slotType = st;
buttonIconX = bx;
buttonIconY = by;
iconsX = xi;
iconsY = yi;
title = t;
body = b;
texture = "/tinkertextures/gui/icons.png";
}
public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b, String tex)
{
slotType = st;
buttonIconX = bx;
buttonIconY = by;
iconsX = xi;
iconsY = yi;
title = t;
body = b;
texture = tex;
}
}
@@ -0,0 +1,97 @@
package tinker.tconstruct.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tinker.tconstruct.logic.ToolStationLogic;
public class ToolStationContainer extends Container
{
InventoryPlayer invPlayer;
ToolStationLogic logic;
String toolName;
Slot[] slots;
SlotTool toolSlot;
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
invPlayer = inventoryplayer;
logic = builderlogic;
toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 115, 38);
this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(builderlogic, 1, 57, 29), new Slot(builderlogic, 2, 39, 38), new Slot(builderlogic, 3, 57, 47) };
for (int iter = 0; iter < 3; iter ++)
this.addSlotToContainer(slots[iter]);
/* 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));
}
toolName = "";
}
//posX and posY must be the same length
public void resetSlots(int[] posX, int[] posY)
{
/* Station inventory */
inventorySlots.clear();
inventoryItemStacks.clear();
this.addSlotToContainer(toolSlot);
for (int iter = 0; iter < posX.length; iter++)
{
slots[iter].xDisplayPosition = posX[iter]+1;
slots[iter].yDisplayPosition = posY[iter]+1;
addSlotToContainer(slots[iter]);
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(invPlayer, column, 8 + column * 18, 142));
}
logic.dumpExtraItems(posX.length, invPlayer.player);
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
{
return null;
}
public void setToolName(String name)
{
toolName = name;
logic.buildTool(name);
detectAndSendChanges();
}
}
@@ -0,0 +1,332 @@
package tinker.tconstruct.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.logic.ToolStationLogic;
import tinker.tconstruct.tools.ToolCore;
import tinker.tconstruct.tools.Weapon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ToolStationGui extends GuiContainer
{
ToolStationLogic logic;
ToolStationContainer toolSlots;
GuiTextField text;
String toolName;
int guiType;
int[] slotX, slotY, iconX, iconY;
String title, body = "";
public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z)
{
super(stationlogic.getGuiContainer(inventoryplayer, world, x, y, z));
this.logic = stationlogic;
toolSlots = (ToolStationContainer) inventorySlots;
text = new GuiTextField(this.fontRenderer, this.xSize / 2 - 5, 8, 30, 12);
this.text.setMaxStringLength(40);
this.text.setEnableBackgroundDrawing(false);
this.text.setVisible(true);
this.text.setCanLoseFocus(false);
this.text.setFocused(true);
this.text.setTextColor(16777215);
resetGui();
}
void resetGui ()
{
this.text.setText("");
toolSlots.setToolName("");
guiType = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2 };
iconY = new int[] { 13, 13, 13 };
title = "\u00A7nRepair and Modification";
body = "The main way to repair or change your tools. Place a tool in the large slot to get started.\n\nThis window not done yet, stay tuned.";
}
public void initGui ()
{
super.initGui();
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.controlList.clear();
ToolGuiElement repair = TConstruct.toolButtons.get(0);
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair
repairButton.enabled = false;
this.controlList.add(repairButton);
for (int iter = 1; iter < TConstruct.toolButtons.size(); iter++)
{
ToolGuiElement element = TConstruct.toolButtons.get(iter);
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22*(iter%5), cornerY+22*(iter/5), element.buttonIconX, element.buttonIconY, element.texture); // Repair
this.controlList.add(button);
}
}
protected void actionPerformed (GuiButton button)
{
((GuiButton) this.controlList.get(guiType)).enabled = true;
guiType = button.id;
button.enabled = false;
ToolGuiElement element = TConstruct.toolButtons.get(guiType);
setSlotType(element.slotType);
iconX = element.iconsX;
iconY = element.iconsY;
title = "\u00A7n"+element.title;
body = element.body;
}
void setSlotType (int type)
{
switch (type)
{
case 0:
slotX = new int[] { 56, 38, 38 }; // Repair
slotY = new int[] { 37, 28, 46 };
break;
case 1:
slotX = new int[] { 56, 56, 56 }; // Three parts
slotY = new int[] { 19, 55, 37 };
break;
case 2:
slotX = new int[] { 56, 56, 14 }; // Two parts
slotY = new int[] { 28, 46, 37 };
break;
case 3:
slotX = new int[] { 38, 47, 56 }; // Double head
slotY = new int[] { 28, 46, 28 };
break;
case 4:
slotX = new int[] { 47, 47, 38, 56 }; // Four parts
slotY = new int[] { 19, 55, 37, 37 };
break;
}
toolSlots.resetSlots(slotX, slotY);
}
public void updateScreen ()
{
super.updateScreen();
this.text.updateCursorCounter();
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.ToolStation"), 6, 6, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
this.fontRenderer.drawString(toolName, this.xSize / 2 - 5, 8, 0);
if (logic.isStackInSlot(0))
drawToolStats();
else
drawToolInformation();
}
void drawToolStats ()
{
ItemStack stack = logic.getStackInSlot(0);
ToolCore tool = (ToolCore) stack.getItem();
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
this.drawCenteredString(fontRenderer, "\u00A7n"+tool.getToolName(), xSize + 63, 8, 16777215);
if (tool instanceof Weapon)
drawWeaponStats(stack, tool, tags);
else if (tool.getHeadType() == 3)
drawDualStats(stack, tool, tags);
else
drawHarvestStats(stack, tool, tags);
}
void drawWeaponStats(ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215);
int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 16777215);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 57, 16777215);
if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 68, 16777215);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip"+tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 68 + tipNum*11, 16777215);
}
else
displayToolTips = false;
}
}
void drawHarvestStats(ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215);
int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 16777215);
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 46, 16777215);
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 57, 16777215);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 79, 16777215);
if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 90, 16777215);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip"+tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 90 + tipNum*11, 16777215);
}
else
displayToolTips = false;
}
}
void drawDualStats(ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 16777215);
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
fontRenderer.drawString("Mining Speeds: ", xSize + 8, 35, 16777215);
fontRenderer.drawString("- "+mineSpeed+", "+mineSpeed2, xSize + 8, 46, 16777215);
fontRenderer.drawString("Harvest Levels:", xSize + 8, 57, 16777215);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 68, 16777215);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, 79, 16777215);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 90, 16777215);
if (tags.hasKey("Tooltip1"));
fontRenderer.drawString("Modifiers:", xSize + 8, 101, 16777215);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip"+tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- "+tipName, xSize + 8, 101 + tipNum*11, 16777215);
}
else
displayToolTips = false;
}
}
void drawToolInformation ()
{
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 16777215);
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 16777215);
}
String getHarvestLevelName (int num)
{
switch (num)
{
case 0:
return "Stone";
case 1:
return "Iron";
case 2:
return "Redstone";
case 3:
return "Obsidian"; //Mithril
case 4:
return "Vulcanite";
case 5:
return "Adamantine";
default:
return String.valueOf(num);
}
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
// Draw the background
int texID = this.mc.renderEngine.getTexture("/tinkertextures/gui/toolstation.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texID);
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
texID = this.mc.renderEngine.getTexture("/tinkertextures/gui/icons.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texID);
// Draw the slots
for (int i = 0; i < slotX.length; i++)
{
this.drawTexturedModalRect(cornerX + slotX[i], cornerY + slotY[i], 0, 0, 18, 18);
if (!logic.isStackInSlot(i + 1))
{
this.drawTexturedModalRect(cornerX + slotX[i], cornerY + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
}
}
// 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);
}
protected void keyTyped (char par1, int keyCode)
{
text.textboxKeyTyped(par1, keyCode);
toolName = text.getText().trim();
toolSlots.setToolName(toolName);
if (keyCode == 1)
{
this.mc.thePlayer.closeScreen();
}
}
/*protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
text.mouseClicked(par1, par2, par3);
}*/
}
@@ -0,0 +1,207 @@
package tinker.tconstruct.crafting;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.items.Pattern;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PatternBuilder
{
public static PatternBuilder instance = new PatternBuilder();
//Map items to their parts with a hashmap
List<ItemKey> materials = new ArrayList<ItemKey>();
HashMap materialSets = new HashMap<String, MaterialSet>();
//We could use IRecipe if it wasn't tied to InventoryCrafting
List<PatternKey> toolPatterns = new ArrayList<PatternKey>();
/* Register methods */
public void registerMaterial (ItemStack material, int value, String key)
{
materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key));
}
public void registerMaterialSet (String key, ItemStack shard, ItemStack rod, int materialID)
{
materialSets.put(key, new MaterialSet(shard, rod, materialID));
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
}
// 1 + 2 = EVERYTHING
public void registerFullMaterial (ItemStack material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
{
materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key));
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
materialSets.put(key, new MaterialSet(shard, rod, materialID));
}
public void addToolPattern (ItemStack pattern, Item toolPart)
{
toolPatterns.add(new PatternKey(pattern.getItem(), pattern.getItemDamage(), toolPart));
}
/* Build tool parts from patterns */
public ItemStack[] getToolPart (ItemStack material, ItemStack pattern, ItemStack otherPattern)
{
if (material != null && pattern != null)
{
ItemKey key = getItemKey(material);
Item toolPart = getMatchingPattern(pattern);
if (key != null && toolPart != null)
{
MaterialSet mat = (MaterialSet) materialSets.get(key.key);
int patternValue = ((Pattern)pattern.getItem()).getPatternCost(pattern.getItemDamage());
int totalMaterial = key.value * material.stackSize;
if (totalMaterial < patternValue) // Not enough material
return null;
else if ( patternValue == key.value ) //Material only
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), null };
else
{
if (patternValue % 2 == 1)
{
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), mat.shard.copy() }; //Material + shard
}
else
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), null };
}
/*if ( patternValue < totalMaterial )
{
if (otherPattern != null)
{
int otherValue = ((Pattern)otherPattern.getItem()).getPatternCost(otherPattern.getItemDamage());
if (patternValue + otherValue <= key.value)
{
Item otherPart = getMatchingPattern(otherPattern);
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), new ItemStack(otherPart, 1, mat.materialID) }; //Material + Material
}
}
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), mat.shard.copy() }; //Material + Shard, copy to avoid weirdness with the itemstack reference
}
else if ( patternValue == key.value )
return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), null }; //Material only
else
return null; //Not a valid match*/
}
}
return null;
}
public int getPartID (ItemStack material)
{
if (material != null)
{
ItemKey key = getItemKey(material);
if (key != null)
{
MaterialSet set = (MaterialSet) materialSets.get(key.key);
return set.materialID;
}
}
return -1;
}
public int getPartValue (ItemStack material)
{
if (material != null)
{
ItemKey key = getItemKey(material);
if (key != null)
return key.value;
}
return 0;
}
public ItemKey getItemKey (ItemStack material)
{
Item mat = material.getItem();
int damage = material.getItemDamage();
for (ItemKey ik : materials)
{
if ( mat == ik.item && (ik.damage == -1 || damage == ik.damage))
return ik;
}
return null;
}
public Item getMatchingPattern (ItemStack pattern)
{
Item pat = pattern.getItem();
int damage = pattern.getItemDamage();
for (PatternKey pk : toolPatterns)
{
if (pat == pk.item && (pk.damage == -1 || damage == pk.damage))
return pk.output;
}
return null;
}
//Small data classes. I would prefer the struct from C#, but we do what we can.
public class ItemKey
{
public final Item item;
public final int damage;
public final int value;
public final String key;
public ItemKey(Item i, int d, int v, String s)
{
item = i;
damage = d;
value = v;
key = s;
}
}
public class PatternKey
{
public final Item item;
public final int damage;
public final Item output;
public PatternKey(Item i, int d, Item o)
{
item = i;
damage = d;
output = o;
}
}
public class MaterialSet
{
public final ItemStack shard;
public final ItemStack rod;
public final int materialID;
public MaterialSet(ItemStack s, ItemStack r, int id)
{
shard = s;
rod = r;
materialID = id;
}
}
//Helper Methods
public void registerMaterial (Block material, int value, String key) { registerMaterial(new ItemStack(material, 1, -1), value, key); }
public void registerMaterial (Item material, int value, String key) { registerMaterial(new ItemStack(material, 1, -1), value, key); }
public void registerFullMaterial (Block material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
{ registerFullMaterial(new ItemStack(material, 1, -1), value, key, shard, rod, materialID); }
public void registerFullMaterial (Item material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
{ registerFullMaterial(new ItemStack(material, 1, -1), value, key, shard, rod, materialID); }
public void registerFullMaterial (Block material, int value, String key, int materialID)
{ registerFullMaterial(new ItemStack(material, 1, -1), value, key, new ItemStack(TConstructContent.toolShard, 1, materialID), new ItemStack(TConstructContent.toolRod, 1, materialID), materialID); }
public void registerFullMaterial (Item material, int value, String key, int materialID)
{ registerFullMaterial(new ItemStack(material, 1, -1), value, key, new ItemStack(TConstructContent.toolShard, 1, materialID), new ItemStack(TConstructContent.toolRod, 1, materialID), materialID); }
}
+213
View File
@@ -0,0 +1,213 @@
package tinker.tconstruct.crafting;
import java.util.*;
import tinker.tconstruct.EnumMaterial;
import tinker.tconstruct.items.ToolPart;
import tinker.tconstruct.modifiers.ToolMod;
import tinker.tconstruct.tools.ToolCore;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ToolBuilder
{
public static ToolBuilder instance = new ToolBuilder();
List<ToolRecipe> combos = new ArrayList<ToolRecipe>();
HashMap<String, String> modifiers = new HashMap<String, String>();
List<ToolMod> toolMods = new ArrayList<ToolMod>();
/* Build tools */
public static void addToolRecipe (ToolCore output, Item head)
{
addToolRecipe(output, head, null);
}
public static void addToolRecipe (ToolCore output, Item head, Item accessory)
{
instance.combos.add(new ToolRecipe(head, accessory, output));
}
public ToolCore getMatchingRecipe (Item head, Item handle, Item accessory)
{
for (ToolRecipe recipe : combos)
{
if (recipe.validHead(head) && recipe.validHandle(handle) && recipe.validAccessory(accessory))
return recipe.getType();
}
return null;
}
//Builds a tool from the parts given
public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, String name)
{
if (headStack != null && headStack.getItem() instanceof ToolCore)
return modifyTool(headStack, handleStack, accessoryStack);
if (headStack == null || handleStack == null) //Nothing to build without these. All tools need at least two parts!
return null;
ToolCore item;
if (accessoryStack == null)
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), null);
else
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem());
if (item == null)
return null;
System.out.println("Tool name: "+item.getToolName());
int head = headStack.getItemDamage();
int handle = handleStack.getItemDamage();
int accessory = -1;
if (accessoryStack != null)
accessory = accessoryStack.getItemDamage();
if (handleStack.getItem() == Item.bone) //Don't worry about stick, it should be metadata 0.
handle = 5;
int durability = (int) (EnumMaterial.durability(head) * EnumMaterial.handleDurability(handle) * item.getDurabilityModifier());
if (accessoryStack != null && (item.getHeadType() == 2 || item.getHeadType() == 3) )
durability = (int) ((EnumMaterial.durability(head) + EnumMaterial.durability(accessory))/2 * EnumMaterial.handleDurability(handle) * item.getDurabilityModifier());
{
/*Item accessoryItem = accessoryStack.getItem();
if (accessoryItem instanceof ToolPart && ((ToolPart)accessoryItem).isHead) //Two heads
durability = (int) ((EnumMaterial.durability(head) + EnumMaterial.durability(accessory))/2 * EnumMaterial.handleDurability(handle) * item.getDurabilityModifier());*/
}
ItemStack tool = new ItemStack(item);
System.out.println("Stack name: "+tool);
NBTTagCompound compound = new NBTTagCompound();
compound.setCompoundTag("InfiTool", new NBTTagCompound());
compound.getCompoundTag("InfiTool").setInteger("Head", head);
compound.getCompoundTag("InfiTool").setInteger("Handle", handle);
compound.getCompoundTag("InfiTool").setInteger("Accessory", accessory);
compound.getCompoundTag("InfiTool").setInteger("RenderHead", head);
compound.getCompoundTag("InfiTool").setInteger("RenderHandle", handle);
compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", accessory);
compound.getCompoundTag("InfiTool").setInteger("Damage", 0); //Damage is damage to the tool
compound.getCompoundTag("InfiTool").setInteger("TotalDurability", durability);
compound.getCompoundTag("InfiTool").setInteger("BaseDurability", durability);
compound.getCompoundTag("InfiTool").setInteger("BonusDurability", 0); //Modifier
compound.getCompoundTag("InfiTool").setFloat("ModDurability", 0f); //Modifier
compound.getCompoundTag("InfiTool").setBoolean("Broken", false);
compound.getCompoundTag("InfiTool").setInteger("Attack", EnumMaterial.attack(head) + item.getDamageVsEntity(null));
compound.getCompoundTag("InfiTool").setInteger("MiningSpeed", EnumMaterial.toolSpeed(head));
if (item.getHeadType() == 2)
{
int hLvl = EnumMaterial.harvestLevel(head);
int shLvl = EnumMaterial.harvestLevel(accessory);
}
else
compound.getCompoundTag("InfiTool").setInteger("HarvestLevel", EnumMaterial.harvestLevel(head));
if (item.getHeadType() == 3)
{
compound.getCompoundTag("InfiTool").setInteger("MiningSpeed2", EnumMaterial.toolSpeed(accessory));
compound.getCompoundTag("InfiTool").setInteger("HarvestLevel2", EnumMaterial.harvestLevel(accessory));
}
compound.getCompoundTag("InfiTool").setInteger("Unbreaking", buildUnbreaking(head, handle, accessory));
compound.getCompoundTag("InfiTool").setFloat("Shoddy", buildShoddy(head, handle, accessory));
int modifiers = 3;
if (accessory == -1)
modifiers += (head == 9 ? 2 : 0) + (handle == 9 ? 1 : 0);
else
modifiers += (head == 9 ? 1 : 0) + (handle == 9 ? 1 : 0) + (accessory == 9 ? 1 : 0);
compound.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers);
if (name != "" && name != null)
{
compound.setCompoundTag("display", new NBTTagCompound());
compound.getCompoundTag("display").setString("Name", "\u00A7f" + name);
}
tool.setTagCompound(compound);
return tool;
}
/*public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot)
{
ItemStack tool = input.copy();
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.removeTag("Built");
for (ToolMod mod : toolMods)
{
ItemStack[] slots = new ItemStack[] {topSlot, bottomSlot};
if (mod.matches(slots, tool))
{
mod.modify(slots, tool);
mod.addMatchingEffect(tool);
}
}
return tool;
}*/
public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot)
{
ItemStack tool = input.copy();
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.removeTag("Built");
boolean built = false;
for (ToolMod mod : toolMods)
{
ItemStack[] slots = new ItemStack[] {topSlot, bottomSlot};
if (mod.matches(slots, tool))
{
built = true;
mod.addMatchingEffect(tool);
mod.modify(slots, tool);
}
}
if (built)
return tool;
else
return null;
}
int buildUnbreaking (int head, int handle, int accessory)
{
int durability = 0;
int dHead = EnumMaterial.unbreaking(head);
int dHandle = EnumMaterial.unbreaking(handle);
int dAccessory = 0;
if (accessory != -1)
dAccessory = EnumMaterial.unbreaking(accessory);
if (dHead > durability)
durability = dHead;
if (dHandle > durability)
durability = dHandle;
if (dAccessory > durability)
durability = dAccessory;
return durability;
}
float buildShoddy (int head, int handle, int accessory)
{
float sHead = EnumMaterial.shoddy(head);
float sHandle = EnumMaterial.shoddy(handle);
if (accessory != -1)
{
float sAccessory = EnumMaterial.shoddy(accessory);
return (sHead + sHandle + sAccessory) / 3f;
}
return (sHead + sHandle) / 2f;
}
public static void registerToolMod(ToolMod mod)
{
instance.toolMods.add(mod);
}
}
@@ -0,0 +1,53 @@
package tinker.tconstruct.crafting;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.tools.ToolCore;
import net.minecraft.item.Item;
/*
* Small class for checking if a particular tool combination is this one
*/
public class ToolRecipe
{
Item head;
Item accessory;
ToolCore item;
public ToolRecipe(Item h, Item acc, ToolCore i)
{
head = h;
accessory = acc;
item = i;
}
public boolean validHead(Item he)
{
if (head == he)
return true;
else
return false;
}
public boolean validHandle(Item handle)
{
return (handle == TConstructContent.toolRod || handle == Item.stick || handle == Item.bone);
}
public boolean validAccessory(Item acc)
{
if (accessory == null && acc == null)
return true;
else if (accessory == TConstructContent.toolRod)
return validHandle(acc);
else if (accessory == acc)
return true;
else
return false;
}
public ToolCore getType()
{
return item;
}
}
+23
View File
@@ -0,0 +1,23 @@
package tinker.tconstruct.items;
import tinker.tconstruct.TConstruct;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.Item;
public class CraftingItem extends Item
{
public CraftingItem(int id, int icon, String tex)
{
super(id);
this.setCreativeTab(TConstruct.materialTab);
this.iconIndex = icon;
this.setTextureFile(tex);
}
@SideOnly(Side.CLIENT)
public int getIconFromDamage(int meta)
{
return this.iconIndex + meta;
}
}
+43
View File
@@ -0,0 +1,43 @@
package tinker.tconstruct.items;
import java.util.List;
import tinker.tconstruct.TConstruct;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
public class Materials extends Item
{
public Materials(int id, int icon, String tex)
{
super(id);
this.setCreativeTab(TConstruct.materialTab);
this.iconIndex = icon;
this.setTextureFile(tex);
}
@SideOnly(Side.CLIENT)
public int getIconFromDamage(int meta)
{
return this.iconIndex + meta;
}
public String getItemNameIS(ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, 6);
return getItemName() + "." +materialNames[arr];
}
public void getSubItems(int id, CreativeTabs tab, List list)
{
for (int i = 0; i < 6; i++)
list.add(new ItemStack(id, 1, i));
}
public static final String[] materialNames = new String[] {
"PaperStack", "SlimeCrystal", "HardenedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot" };
}
+89
View File
@@ -0,0 +1,89 @@
package tinker.tconstruct.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import tinker.common.IPattern;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Pattern extends CraftingItem
implements IPattern
{
public Pattern(int id, int icon, String tex)
{
super(id, icon, tex);
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setContainerItem(this);
this.setMaxStackSize(1);
}
public String getItemNameIS (ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, 12);
return super.getItemName() + "." + patternName[arr];
}
public static final String[] patternName = new String[] {
"blank", "rod", "pickaxe", "shovel", "axe", "blade", "largeguard", "medguard", "crossbar", "binding", "frypan", "sign", "lumber" };
public void getSubItems (int id, CreativeTabs tab, List list)
{
for (int i = 0; i < patternName.length; i++)
list.add(new ItemStack(id, 1, i));
}
public ItemStack getContainerItemStack (ItemStack stack)
{
return stack;
}
public boolean doesContainerItemLeaveCraftingGrid (ItemStack stack)
{
return false;
}
/* Tags and information about the pattern */
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
float cost = getPatternCost(stack.getItemDamage()) / 2f;
if (cost > 0)
{
if (cost - (int)cost < 0.1)
list.add("Material Cost: "+(int)cost);
else
list.add("Material Cost: "+cost);
}
else
{
list.add("Temporary: Craft any pattern to get another");
}
}
//2 for full material, 1 for half.
public int getPatternCost (int meta)
{
switch (meta)
{
case 1: return 1;
case 2: return 2;
case 3: return 2;
case 4: return 2;
case 5: return 2;
case 6: return 1;
case 7: return 1;
case 8: return 1;
case 9: return 1;
case 10: return 2;
case 11: return 2;
case 12: return 4;
default: return 0;
}
}
}
+38
View File
@@ -0,0 +1,38 @@
package tinker.tconstruct.items;
import java.util.List;
import tinker.tconstruct.TConstruct;
import tinker.tconstruct.client.TProxyClient;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ToolPart extends CraftingItem
{
public ToolPart(int id, int icon, String tex)
{
super(id, icon, tex);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public String getItemNameIS(ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, 12);
return getItemName() + "." +toolMaterialNames[arr];
}
public void getSubItems(int id, CreativeTabs tab, List list)
{
for (int i = 0; i < 13; i++)
list.add(new ItemStack(id, 1, i));
}
public static final String[] toolMaterialNames = new String[] {
"Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn" };
}
+65
View File
@@ -0,0 +1,65 @@
package tinker.tconstruct.logic;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import tinker.common.IActiveLogic;
import tinker.common.InventoryLogic;
import cpw.mods.fml.common.registry.GameRegistry;
/* Slots
* 0: Frying pan item
* 1: Fuel
* 2-9: Food
*/
public abstract class EquipLogic extends InventoryLogic
{
public EquipLogic(int invSize)
{
super(invSize);
}
public void setEquipmentItem(ItemStack stack)
{
inventory[0] = stack.copy();
}
public boolean hasEquipmentItem()
{
return inventory[0] != null;
}
public ItemStack getEquipmentItem()
{
return inventory[0];
}
/*@Override
public ItemStack getStackInSlot(int slot)
{
return inventory[slot +1];
}
public boolean isStackInSlot(int slot)
{
return inventory[slot +1] != null;
}
@Override
public int getSizeInventory()
{
return inventory.length - 1;
}*/
}
+290
View File
@@ -0,0 +1,290 @@
package tinker.tconstruct.logic;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tinker.common.IActiveLogic;
import tinker.common.InventoryLogic;
import tinker.tconstruct.client.gui.FrypanContainer;
import cpw.mods.fml.common.registry.GameRegistry;
/* Slots
* 0: Frying pan item
* 1: Fuel
* 2-9: Food
*/
public class FrypanLogic extends EquipLogic
implements IActiveLogic
{
boolean active;
public int fuel;
public int fuelGague;
public int progress;
public FrypanLogic()
{
super(10);
active = false;
}
@Override
public String getInvName ()
{
return "crafters.frypan";
}
@Override
public boolean getActive ()
{
return active;
}
@Override
public void setActive (boolean flag)
{
active = flag;
}
/* Fuel gauge */
public int gaugeProgressScaled (int scale)
{
return (progress * scale) / 1000;
}
public int gaugeFuelScaled (int scale)
{
if (fuelGague == 0)
{
fuelGague = fuel;
if (fuelGague == 0)
{
fuelGague = 1000;
}
}
return (fuel * scale) / fuelGague;
}
/* Item cooking */
public void updateEntity ()
{
boolean burning = isBurning();
boolean updateInventory = false;
if (fuel <= 0 && canCook())
{
fuel = fuelGague = getItemBurnTime(inventory[1]) * 10;
if (fuel > 0)
{
if (inventory[1].getItem().hasContainerItem()) //Fuel slot
{
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
}
else
{
inventory[1].stackSize--;
}
if (inventory[1].stackSize <= 0)
{
inventory[1] = null;
}
updateInventory = true;
}
}
if (isBurning() && canCook())
{
progress++;
if (progress >= 1000)
{
progress = 0;
cookItems();
updateInventory = true;
}
}
else
{
progress = 0;
}
if (fuel > 0)
{
fuel--;
}
if (burning != isBurning())
{
setActive(isBurning());
updateInventory = true;
}
if (updateInventory)
{
onInventoryChanged();
}
}
public void cookItems ()
{
System.out.println("Trying to cook");
if (!canCook())
return;
System.out.println("Can cook");
for (int id = 2; id < 10; id++) //Check every slot
{
if (canCook())
{
ItemStack result = getResultFor(inventory[id]);
if (result != null)
{
int ids = 2;
boolean placed = false;
while (ids < 10 && !placed) //Try to merge stacks first
{
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
{
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
{
inventory[ids].stackSize += result.stackSize;
placed = true;
}
else
{
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
result.stackSize -= decrement;
}
}
ids++;
}
ids = 2;
while (!placed && ids < 10) //Place remaining in slot
{
if (inventory[ids] == null)
{
inventory[ids] = result;
placed = true;
}
ids++;
}
if (placed)
decrStackSize(id, 1);
}
}
}
}
public boolean canCook ()
{
for (int id = 2; id < 10; id++)
{
if (inventory[id] == null) //Nothing here!
continue;
ItemStack result = getResultFor(inventory[id]);
if (result == null) //Doesn't cook into anything
continue;
for (int slotid = 2; slotid < 10; slotid++)
{
if (inventory[slotid] == null)
return true;
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
return true;
}
}
return false;
}
public boolean isBurning ()
{
return fuel > 0;
}
public ItemStack getResultFor (ItemStack stack)
{
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
return result.copy();
return null;
}
public static int getItemBurnTime (ItemStack stack)
{
if (stack == null)
{
return 0;
}
else
{
int itemID = stack.getItem().itemID;
Item item = stack.getItem();
if (stack.getItem() instanceof ItemBlock && Block.blocksList[itemID] != null)
{
Block var3 = Block.blocksList[itemID];
if (var3 == Block.woodSingleSlab)
{
return 150;
}
if (var3.blockMaterial == Material.wood)
{
return 300;
}
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemSword && ((ItemSword) item).func_77825_f().equals("WOOD"))
return 200;
if (item instanceof ItemHoe && ((ItemHoe) item).func_77842_f().equals("WOOD"))
return 200;
if (itemID == Item.stick.itemID)
return 100;
if (itemID == Item.coal.itemID)
return 1600;
if (itemID == Item.bucketLava.itemID)
return 20000;
if (itemID == Block.sapling.blockID)
return 100;
if (itemID == Item.blazeRod.itemID)
return 2400;
return GameRegistry.getFuelValue(stack);
}
}
/* NBT */
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
active = tags.getBoolean("Active");
fuel = tags.getInteger("Fuel");
fuelGague = tags.getInteger("FuelGague");
}
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
tags.setBoolean("Active", active);
tags.setInteger("Fuel", fuel);
tags.setInteger("FuelGague", fuelGague);
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new FrypanContainer(inventoryplayer, this);
}
}
+149
View File
@@ -0,0 +1,149 @@
package tinker.tconstruct.logic;
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.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
public class LavaTankLogic extends TileEntity
implements ITankContainer
{
public LiquidTank tank;
public int amount;
public int max;
public LiquidStack liquid;
public LavaTankLogic()
{
tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
max = 1;
amount = 0;
}
@Override
public int fill (ForgeDirection from, LiquidStack resource, boolean doFill)
{
return fill(0, resource, doFill);
}
@Override
public int fill (int tankIndex, LiquidStack resource, boolean doFill)
{
if (resource == null)
return 0;
if (liquid == null)
{
liquid = resource;
amount = resource.amount;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return amount;
}
else if (resource.amount + amount > max*1000)
{
if (doFill)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
amount = 4000;
}
return resource.amount + amount - 4000;
}
else
{
if (doFill)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
amount += resource.amount;
}
return amount;
}
}
@Override
public LiquidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
{
return drain(0, maxDrain, doDrain);
}
@Override
public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain)
{
if (amount - maxDrain < 0)
{
LiquidStack liq = new LiquidStack(liquid.itemID, 0, liquid.itemMeta);
if (doDrain)
{
amount = 0;
liquid = null;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return liq;
}
else
{
if (doDrain)
{
amount -= maxDrain;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return new LiquidStack(liquid.itemID, amount - maxDrain, liquid.itemMeta);
}
}
@Override
public ILiquidTank[] getTanks (ForgeDirection direction)
{
return new ILiquidTank[] { (ILiquidTank) this };
}
@Override
public ILiquidTank getTank (ForgeDirection direction, LiquidStack type)
{
return (ILiquidTank) this;
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
this.amount = par1NBTTagCompound.getInteger("amount");
this.liquid = new LiquidStack(par1NBTTagCompound.getInteger("itemID"), amount, par1NBTTagCompound.getInteger("itemMeta"));
super.readFromNBT(par1NBTTagCompound);
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
if (liquid != null)
{
par1NBTTagCompound.setInteger("itemID", liquid.itemID);
par1NBTTagCompound.setInteger("amount", this.amount);
par1NBTTagCompound.setInteger("itemMeta", liquid.itemMeta);
}
else
{
par1NBTTagCompound.setInteger("itemID", 0);
par1NBTTagCompound.setInteger("amount", 0);
par1NBTTagCompound.setInteger("itemMeta", 0);
}
super.writeToNBT(par1NBTTagCompound);
}
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
worldObj.getBlockTileEntity(xCoord, yCoord, zCoord).readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,169 @@
package tinker.tconstruct.logic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import tinker.common.InventoryLogic;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.client.gui.PartCrafterChestContainer;
import tinker.tconstruct.client.gui.PartCrafterContainer;
import tinker.tconstruct.crafting.PatternBuilder;
import tinker.tconstruct.items.Pattern;
public class PartCrafterLogic extends InventoryLogic
{
boolean craftedTop;
boolean craftedBottom;
public PartCrafterLogic()
{
super(10);
craftedTop = false;
craftedBottom = false;
}
@Override
public String getInvName ()
{
return "toolstation.parts";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
for (int xPos = x-1; xPos <= x+1; xPos++)
{
for (int zPos = z-1; zPos <= z+1; zPos++)
{
TileEntity tile = world.getBlockTileEntity(xPos, y, zPos);
if (tile != null && tile instanceof PatternChestLogic)
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic)tile);
//return ((PatternHolderLogic) tile).getGuiContainer(player.inventory, world, x, y, z);
}
}
System.out.println("Regular container");
return new PartCrafterContainer(inventoryplayer, this);
}
//Called when emptying a slot, not when another item is placed in it
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack returnStack = super.decrStackSize(slot, quantity);
if (slot == 4 || slot == 5)
{
if (!craftedTop)
{
int value = PatternBuilder.instance.getPartValue(inventory[1]);
int cost = ((Pattern)inventory[0].getItem()).getPatternCost(inventory[0].getItemDamage());
if (value > 0)
{
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(1, decrease); //Call super to avoid crafting again
}
}
if (inventory[4] != null || inventory[5] != null)
craftedTop = true;
else
craftedTop = false;
}
if (!craftedTop)
buildTopPart();
if (slot == 6 || slot == 7)
{
if (!craftedBottom)
{
int value = PatternBuilder.instance.getPartValue(inventory[3]);
int cost = ((Pattern)inventory[2].getItem()).getPatternCost(inventory[2].getItemDamage());
if (value > 0)
{
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(3, decrease); //Call super to avoid crafting again
}
}
if (inventory[6] != null || inventory[7] != null)
craftedBottom = true;
else
craftedBottom = false;
}
if (!craftedBottom)
buildBottomPart();
return returnStack;
}
//Called when a slot has something placed into it.
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if ((slot == 0 || slot == 1) && !craftedTop)
buildTopPart();
if ((slot == 2 || slot == 3) && !craftedBottom)
buildBottomPart();
}
void buildTopPart ()
{
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[1], inventory[0], inventory[2]);
if (parts != null)
{
inventory[4] = parts[0];
inventory[5] = parts[1];
}
else
{
inventory[4] = inventory[5] = null;
}
}
void buildBottomPart ()
{
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[2], inventory[0]);
if (parts != null)
{
inventory[6] = parts[0];
inventory[7] = parts[1];
}
else
{
inventory[6] = inventory[7] = null;
}
}
public boolean shouldRemoveItemsForCrafting (int slot)
{
if ((slot == 4 || slot == 5) && craftedTop)
return false;
if ((slot == 6 || slot == 7) && craftedBottom)
return false;
return true;
}
/* NBT */
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
craftedTop = tags.getBoolean("CraftedTop");
craftedBottom = tags.getBoolean("CraftedBottom");
}
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
tags.setBoolean("CraftedTop", craftedTop);
tags.setBoolean("CraftedBottom", craftedBottom);
}
}
@@ -0,0 +1,27 @@
package tinker.tconstruct.logic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.world.World;
import tinker.common.InventoryLogic;
import tinker.tconstruct.client.gui.PatternChestContainer;
public class PatternChestLogic extends InventoryLogic
{
public PatternChestLogic()
{
super(30);
}
@Override
public String getInvName ()
{
return "toolstation.patternholder";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new PatternChestContainer(inventoryplayer, this);
}
}
+104
View File
@@ -0,0 +1,104 @@
package tinker.tconstruct.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.world.World;
import tinker.common.IActiveLogic;
import tinker.common.IFacingLogic;
import tinker.common.InventoryLogic;
/* Simple class for storing items in the block
*/
public class SmelteryLogic extends InventoryLogic
implements IActiveLogic, IFacingLogic
{
int temperature;
int useTime;
byte direction;
public SmelteryLogic()
{
super(5);
}
@Override
public String getInvName ()
{
return "crafters.Smeltery";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return null;
}
@Override
public byte getDirection()
{
return direction;
}
@Override
public void setDirection(byte dir)
{
direction = dir;
}
@Override
public boolean getActive()
{
return false;
}
@Override
public void setActive(boolean flag)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public boolean canFaceVertical()
{
return false;
}
public void scanWorld()
{
switch(getDirection())
{
case 2: // +z
//worldObj.setBlockWithNotify(xCoord, yCoord, zCoord+1, Block.dirt.blockID);
placeBlockRing(xCoord, yCoord, zCoord+2);
break;
case 3: // -z
//worldObj.setBlockWithNotify(xCoord, yCoord, zCoord-1, Block.dirt.blockID);
placeBlockRing(xCoord, yCoord, zCoord-2);
break;
case 4: // +x
//worldObj.setBlockWithNotify(xCoord+1, yCoord, zCoord, Block.dirt.blockID);
placeBlockRing(xCoord+2, yCoord, zCoord);
break;
case 5: // -x
//worldObj.setBlockWithNotify(xCoord-1, yCoord, zCoord, Block.dirt.blockID);
placeBlockRing(xCoord-2, yCoord, zCoord);
break;
}
}
public void placeBlockRing(int x, int y, int z)
{
for (int xPos = x-1; xPos <= x+1; xPos++)
{
worldObj.setBlockWithNotify(xPos, y, z-2, Block.dirt.blockID);
worldObj.setBlockWithNotify(xPos, y, z+2, Block.dirt.blockID);
}
for (int zPos = z-1; zPos <= z+1; zPos++)
{
worldObj.setBlockWithNotify(x-2, y, zPos, Block.dirt.blockID);
worldObj.setBlockWithNotify(x+2, y, zPos, Block.dirt.blockID);
}
}
}
@@ -0,0 +1,98 @@
package tinker.tconstruct.logic;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tinker.common.InventoryLogic;
import tinker.tconstruct.client.gui.ToolStationContainer;
import tinker.tconstruct.crafting.ToolBuilder;
/* Simple class for storing items in the block
*/
public class ToolStationLogic extends InventoryLogic
{
ToolStationContainer container;
ItemStack previousTool;
String toolName;
public ToolStationLogic()
{
super(5);
}
@Override
public ItemStack getStackInSlotOnClosing (int var1)
{
return null;
}
@Override
public String getInvName ()
{
return "toolstation.crafting";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
container = new ToolStationContainer(inventoryplayer, this);
return container;
}
public void onInventoryChanged ()
{
buildTool("");
if (this.worldObj != null)
{
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.updateTileEntityChunkAndDoNothing(this.xCoord, this.yCoord, this.zCoord, this);
}
}
public void buildTool (String name)
{
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
if (inventory[0] == null)
inventory[0] = tool;
else
{
NBTTagCompound tags = inventory[0].getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
inventory[0] = tool;
}
}
if (container != null)
container.detectAndSendChanges();
}
void consumeItems ()
{
for (int i = 1; i <= 3; i++)
super.decrStackSize(i, 1);
if (container != null)
container.detectAndSendChanges();
}
public void dumpExtraItems (int usedSlots, EntityPlayer player)
{
if (!worldObj.isRemote)
{
for (int iter = 0; iter < inventory.length; iter++)
{
if (iter > usedSlots && inventory[iter] != null)
{
EntityItem entityitem = new EntityItem(worldObj, player.posX, player.posY - 1.0D, player.posZ, inventory[iter]);
worldObj.spawnEntityInWorld(entityitem);
entityitem.onCollideWithPlayer(player);
}
}
}
}
}
@@ -0,0 +1,35 @@
package tinker.tconstruct.modifiers;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Adds a boolean NBTTag */
public class ModBoolean extends ToolMod
{
public ModBoolean(ItemStack[] items, int effect, String tag)
{
super(items, effect, tag);
}
protected boolean canModify (ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
{
tags.setBoolean(key, true);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
}
}
}
@@ -0,0 +1,68 @@
package tinker.tconstruct.modifiers;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Adds an integer NBTTag */
public class ModDurability extends ToolMod
{
String tooltipName;
String color;
int durability;
float modifier;
int miningLevel;
public ModDurability(ItemStack[] items, int effect, int dur, float mod, int level, String k, String tip, String c)
{
super(items, effect, k);
durability = dur;
modifier = mod;
miningLevel = level;
tooltipName = tip;
color = c;
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey(key))
return false;
return super.canModify(tool, input);
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int base = tags.getInteger("BaseDurability");
int bonus = tags.getInteger("BonusDurability");
float modDur = tags.getFloat("ModDurability");
bonus += durability;
modDur += modifier;
int total = (int) ((base + bonus) * (modDur+1f));
if (total <= 0)
total = 1;
tags.setInteger("TotalDurability", total);
tags.setInteger("BonusDurability", bonus);
tags.setFloat("ModDurability", modDur);
int mLevel = tags.getInteger("HarvestLevel");
if (mLevel < miningLevel)
tags.setInteger("HarvestLevel", miningLevel);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
tags.setBoolean(key, true);
String modTip = color+key;
addToolTip(tool, tooltipName, modTip);
}
}
@@ -0,0 +1,71 @@
package tinker.tconstruct.modifiers;
import java.util.*;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* IC2 support */
public class ModElectric extends ModBoolean
{
public ArrayList<ItemStack> circuits = new ArrayList<ItemStack>();
public ArrayList<ItemStack> batteries = new ArrayList<ItemStack>();
public ModElectric()
{
super(new ItemStack[0], 9, "Electric");
}
@Override
public boolean matches (ItemStack[] input, ItemStack tool)
{
if (input[0] == null || input[1] == null)
return false;
boolean circuit = false;
boolean battery = false;
for (ItemStack stack : circuits)
{
if (stack.isItemEqual(input[0]) || stack.isItemEqual(input[1]))
circuit = true;
}
for (ItemStack stack : batteries)
{
if (stack.isItemEqual(input[0]) || stack.isItemEqual(input[1]))
battery = true;
}
return circuit && battery && canModify(tool);
}
@Override
protected boolean canModify (ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0;
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound();
if (!tags.hasKey(key))
{
tags.setBoolean(key, true);
int modifiers = tags.getCompoundTag("InfiTool").getInteger("Modifiers");
modifiers -= 1;
tags.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers);
tags.setInteger("charge", 0);
tags.setDouble("electricity", 0);
tags.setInteger(key, 1);
addModifierTip(tool, "\u00a7eElectric");
}
}
}
@@ -0,0 +1,46 @@
package tinker.tconstruct.modifiers;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Adds an integer NBTTag */
public class ModInteger extends ToolMod
{
String key;
int initialIncrease;
int secondaryIncrease;
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase)
{
super(items, effect, dataKey);
initialIncrease = secondaryIncrease = increase;
}
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase1, int increase2)
{
super(items, effect, dataKey);
initialIncrease = increase1;
secondaryIncrease = increase2;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey(key))
{
int increase = tags.getInteger(key);
increase += secondaryIncrease;
}
else
{
tags.setInteger(key, initialIncrease);
}
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
}
}
@@ -0,0 +1,43 @@
package tinker.tconstruct.modifiers;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Little mod for actually adding the lapis modifier */
public class ModLapisBase extends ToolMod
{
String key;
public ModLapisBase(ItemStack[] items, int effect)
{
super(items, effect, "Lapis");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0;
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setBoolean(key, true);
String modName = "\u00a79Lapis (0/100)";
int tooltipIndex = addToolTip(tool, "\u00a79Fortune", modName);
int[] keyPair = new int[] { 0, tooltipIndex };
tags.setIntArray(key, keyPair);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
}
}
@@ -0,0 +1,117 @@
package tinker.tconstruct.modifiers;
import java.util.Iterator;
import java.util.Map;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ModLapisIncrease extends ToolMod
{
String key;
int increase;
public ModLapisIncrease(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Lapis");
increase = inc;
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return false;
System.out.println("Checking modify");
int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + increase <= 100)
return true;
else
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int keyPair[] = tags.getIntArray(key);
keyPair[0] += increase;
tags.setIntArray(key, keyPair);
if (keyPair[0] >= 100)
addEnchantment(tool, Enchantment.fortune, 3);
else if (keyPair[0] >= 40)
addEnchantment(tool, Enchantment.fortune, 2);
else if (keyPair[0] >= 10)
addEnchantment(tool, Enchantment.fortune, 1);
updateModTag(tool, keyPair);
}
public void addEnchantment(ItemStack tool, Enchantment enchant, int level)
{
/*if (!tool.stackTagCompound.hasKey("ench"))
{
tool.stackTagCompound.setTag("ench", new NBTTagList("ench"));
}*/
//NBTTagList tags = (NBTTagList)tool.stackTagCompound.getTag("ench");
NBTTagList tags = new NBTTagList("ench");
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
Iterator iterator = enchantMap.keySet().iterator();
int index;
int lvl;
boolean hasEnchant = false;
while (iterator.hasNext())
{
NBTTagCompound enchantTag = new NBTTagCompound();
index = ((Integer)iterator.next()).intValue();
lvl = (Integer) enchantMap.get(index);
if (index == enchant.effectId)
{
hasEnchant = true;
enchantTag.setShort("id", (short)index);
enchantTag.setShort("lvl", (short)((byte)level));
tags.appendTag(enchantTag);
}
else
{
enchantTag.setShort("id", (short)index);
enchantTag.setShort("lvl", (short)((byte)lvl));
tags.appendTag(enchantTag);
}
}
if (!hasEnchant)
{
NBTTagCompound enchantTag = new NBTTagCompound();
enchantTag.setShort("id", (short)enchant.effectId);
enchantTag.setShort("lvl", (short)((byte)level));
tags.appendTag(enchantTag);
}
//this.stackTagCompound.setTag("ench", new NBTTagList("ench"));
tool.stackTagCompound.setTag("ench", tags);
/*if (enchantMap.containsKey(enchant.effectId))
{
map.
}*/
//NBTTagList enchantTags = (NBTTagList)tool.stackTagCompound.getTag("ench");
/*NBTTagCompound var4 = new NBTTagCompound();
var4.setShort("id", (short)par1Enchantment.effectId);
var4.setShort("lvl", (short)((byte)par2));
enchantTags.appendTag(var4);*/
}
void updateModTag (ItemStack tool, int[] keys)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
String tip = "ModifierTip"+keys[1];
String modName = "\u00a79Lapis ("+keys[0]+"/100)";
tags.setString(tip, modName);
}
}
@@ -0,0 +1,94 @@
package tinker.tconstruct.modifiers;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModRedstone extends ToolMod
{
String tooltipName;
int increase;
int max;
public ModRedstone(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Redstone");
tooltipName = "\u00a74Speed";
increase = inc;
max = 25;
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0;
int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + increase <= keyPair[1])
return true;
else if (keyPair[0] == keyPair[1])
return tags.getInteger("Modifiers") > 0;
else
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey(key))
{
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] == max)
{
keyPair[0] += increase;
keyPair[1] += max;
tags.setIntArray(key, keyPair);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
}
else
{
keyPair[0] += increase;
tags.setIntArray(key, keyPair);
}
updateModTag(tool, keyPair);
}
else
{
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
String modName = "\u00a74Redstone ("+increase+"/"+max+")";
int tooltipIndex = addToolTip(tool, tooltipName, modName);
int[] keyPair = new int[] { increase, max, tooltipIndex };
tags.setIntArray(key, keyPair);
}
int miningSpeed = tags.getInteger("MiningSpeed");
miningSpeed += (increase*8);
tags.setInteger("MiningSpeed", miningSpeed);
if (tags.hasKey("MiningSpeed2"))
{
int miningSpeed2 = tags.getInteger("MiningSpeed2");
miningSpeed2 += (increase*8);
tags.setInteger("MiningSpeed", miningSpeed2);
}
}
void updateModTag(ItemStack tool, int[] keys)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
String tip = "ModifierTip"+keys[2];
String modName = "\u00a7cRedstone ("+keys[0]+"/"+keys[1]+")";
tags.setString(tip, modName);
}
}
@@ -0,0 +1,73 @@
package tinker.tconstruct.modifiers;
import tinker.tconstruct.crafting.PatternBuilder;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Little mod for actually adding the lapis modifier */
public class ModRepair extends ToolMod
{
public ModRepair()
{
super(new ItemStack[0], 0, "");
}
@Override
public boolean matches (ItemStack[] input, ItemStack tool)
{
return canModify(tool, input);
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
if ((input[0] == null && input[1] == null) || (input[0] != null && input[1] != null)) //Only valid for one itemstack
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.getInteger("Damage") > 0)
{
int headID = tags.getInteger("Head");
int matID = -1;
if (input [0] != null)
matID = PatternBuilder.instance.getPartID(input[0]);
else
matID = PatternBuilder.instance.getPartID(input[1]);
if (matID == headID)
return true;
}
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setBoolean("Broken", false);
int damage = tags.getInteger("Damage");
int dur = tags.getInteger("TotalDurability");
int materialValue = 0;
if (input [0] != null)
materialValue = PatternBuilder.instance.getPartValue(input[0]);
else
materialValue = PatternBuilder.instance.getPartValue(input[1]);
int increase = (int) (50 + (dur * 0.4f * materialValue));
damage -= increase;
if (damage < 0)
damage = 0;
tags.setInteger("Damage", damage);
int repair = tags.getInteger("RepairCount");
repair += 1;
tags.setInteger("RepairCount", repair);
}
@Override
public void addMatchingEffect (ItemStack tool) {}
}
+151
View File
@@ -0,0 +1,151 @@
package tinker.tconstruct.modifiers;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public abstract class ToolMod
{
// The ItemStacks used to compare against
//ItemStack[] stacks;
public final String key;
public final List stacks;
public final int effectIndex; //255 is always blank
public ToolMod(ItemStack[] items, int effect, String dataKey)
{
//recipeItems = items;
List<ItemStack> itemstacks = new ArrayList<ItemStack>();
for (int iter = 0; iter < items.length; iter++)
itemstacks.add(items[iter]);
stacks = itemstacks;
effectIndex = effect;
key = dataKey;
}
/** Checks to see if the inputs match the stored items
* Note: Works like ShapelessRecipes
*
* @param input The ItemStacks to compare against
* @param tool Item to modify, used for restrictions
* @return Whether the recipe matches the input
*/
public boolean matches (ItemStack[] input, ItemStack tool)
{
if (!canModify(tool, input))
return false;
ArrayList list = new ArrayList(this.stacks);
for (int iter = 0; iter < input.length; ++iter)
{
ItemStack craftingStack = input[iter];
if (craftingStack != null)
{
boolean canCraft = false;
Iterator iterate = list.iterator();
while (iterate.hasNext())
{
ItemStack removeStack = (ItemStack) iterate.next();
if (craftingStack.itemID == removeStack.itemID && (removeStack.getItemDamage() == -1 || craftingStack.getItemDamage() == removeStack.getItemDamage()))
{
canCraft = true;
list.remove(removeStack);
break;
}
}
if (!canCraft)
{
return false;
}
}
}
return list.isEmpty();
}
/**
*
* @param tool Tool to compare against
* @return Whether the tool can be modified
*/
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
return tags.getInteger("Modifiers") > 0;
}
/** Modifies the tool. Adds nbttags, changes existing ones, ticks down modification counter, etc
*
* @param input ItemStacks to pull info from
* @param tool The tool to modify
*/
public abstract void modify (ItemStack[] input, ItemStack tool);
public void addMatchingEffect (ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey("Effect3") || tags.hasKey(key))
return;
else if (tags.hasKey("Effect2"))
{
System.out.println("Adding Effect 3");
tags.setInteger("Effect3", effectIndex);
}
else if (tags.hasKey("Effect1"))
{
System.out.println("Adding Effect 2");
tags.setInteger("Effect2", effectIndex);
}
else
{
System.out.println("Adding Effect 1");
tags.setInteger("Effect1", effectIndex);
}
}
protected int addModifierTip (ItemStack tool, String modifierTip)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int tipNum = 0;
while (true)
{
tipNum++;
String tip = "Tooltip" + tipNum;
if (!tags.hasKey(tip))
{
tags.setString(tip, "");
String modTip = "ModifierTip" + tipNum;
tags.setString(modTip, modifierTip);
return tipNum;
}
}
}
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int tipNum = 0;
while (true)
{
tipNum++;
String tip = "Tooltip" + tipNum;
if (!tags.hasKey(tip))
{
tags.setString(tip, tooltip);
String modTip = "ModifierTip" + tipNum;
tags.setString(modTip, modifierTip);
return tipNum;
}
}
}
}
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff. Show more