This commit is contained in:
mDiyo 2013-01-24 23:54:11 -08:00
parent 7e7972f83e
commit 0ddf7ae8b5
22 changed files with 524 additions and 91 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -57,7 +57,7 @@ public abstract class InventoryBlock extends BlockContainer
{
ItemStack stack = logic.getStackInSlot(iter);
if (stack != null)
if (stack != null && logic.canDropInventorySlot(iter))
{
float jumpX = TConstruct.tRand.nextFloat() * 0.8F + 0.1F;
float jumpY = TConstruct.tRand.nextFloat() * 0.8F + 0.1F;

View File

@ -50,6 +50,11 @@ public abstract class InventoryLogic extends TileEntity
return 64;
}
public boolean canDropInventorySlot(int slot)
{
return true;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{

View File

@ -4,17 +4,29 @@ import ic2.api.ElectricItem;
import ic2.api.ICustomElectricItem;
import ic2.api.IElectricItem;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.stats.AchievementList;
import net.minecraft.stats.StatList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
@ -25,8 +37,9 @@ import cpw.mods.fml.client.FMLClientHandler;
public class AbilityHelper
{
static Minecraft mc;
static Random random = new Random();
/* Blocks */
/* Normal interactions */
public static boolean onBlockChanged (ItemStack stack, World world, int bID, int x, int y, int z, EntityLiving player, Random random)
{
if (!stack.hasTagCompound())
@ -46,6 +59,216 @@ public class AbilityHelper
return true;
}
/*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)
if (mob.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), attack))
{
damageTool(stack, 1, tags, player, false);
if (tags.getCompoundTag("InfiTool").getBoolean("Necrotic"))
player.heal(1);
}
else
mob.attackEntityFrom(DamageSource.causeMobDamage(player), attack);
if (tags.getCompoundTag("InfiTool").hasKey("Fiery"))
{
mob.setFire(tags.getCompoundTag("InfiTool").getInteger("Fiery")/5+1);
}
}
}*/
public static void onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity, ToolCore tool)
{
if (entity.canAttackWithItem())
{
if (!entity.func_85031_j(player)) // can't attack this entity
{
NBTTagCompound tags = stack.getTagCompound();
NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool");
int damage = toolTags.getInteger("Attack");
boolean broken = toolTags.getBoolean("Broken");
int durability = tags.getCompoundTag("InfiTool").getInteger("Damage");
float shoddy = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
float damageModifier = -shoddy * durability / 100f;
if (player.isPotionActive(Potion.damageBoost))
{
damage += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier();
}
if (player.isPotionActive(Potion.weakness))
{
damage -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier();
}
float knockback = 0;
int enchantDamage = 0;
if (entity instanceof EntityLiving)
{
enchantDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLiving)entity);
knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving)entity);
}
damage += damageModifier;
if (player.isSprinting())
{
knockback++;
float lunge = tool.chargeAttack();
if (lunge > 1f)
{
knockback += lunge - 1.0f;
damage *= lunge;
}
}
if (damage > 0 || enchantDamage > 0)
{
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLiving;
if (criticalHit)
{
damage += random.nextInt(damage / 2 + 2);
}
damage += enchantDamage;
boolean var6 = false;
int fireAspect = EnchantmentHelper.getFireAspectModifier(player);
if (entity instanceof EntityLiving && fireAspect > 0 && !entity.isBurning())
{
var6 = true;
entity.setFire(1);
}
if (broken)
damage = 1;
boolean causedDamage = false;
if (tool.pierceArmor())
causedDamage = entity.attackEntityFrom(causePlayerPiercingDamage(player), damage);
else
causedDamage = entity.attackEntityFrom(DamageSource.causePlayerDamage(player), damage);
if (causedDamage)
{
damageTool(stack, 1, player, false);
int drain = toolTags.getInteger("Necrotic");
if (drain > 0)
player.heal(drain);
if (knockback > 0)
{
entity.addVelocity((double)(-MathHelper.sin(player.rotationYaw * (float)Math.PI / 180.0F) * (float)knockback * 0.5F), 0.1D, (double)(MathHelper.cos(player.rotationYaw * (float)Math.PI / 180.0F) * (float)knockback * 0.5F));
player.motionX *= 0.6D;
player.motionZ *= 0.6D;
player.setSprinting(false);
}
if (criticalHit)
{
player.onCriticalHit(entity);
}
if (enchantDamage > 0)
{
player.onEnchantmentCritical(entity);
}
if (damage >= 18)
{
player.triggerAchievement(AchievementList.overkill);
}
player.setLastAttackingEntity(entity);
if (entity instanceof EntityLiving)
{
EnchantmentThorns.func_92044_a(player, (EntityLiving)entity, random);
}
}
if (entity instanceof EntityLiving)
{
stack.hitEntity((EntityLiving)entity, player);
if (entity.isEntityAlive())
{
alertPlayerWolves(player, (EntityLiving)entity, true);
}
player.addStat(StatList.damageDealtStat, damage);
if (fireAspect > 0 && causedDamage)
{
fireAspect *= 4;
if (toolTags.hasKey("Fiery"))
{
fireAspect += toolTags.getInteger("Fiery")/5+1;
}
entity.setFire(fireAspect);
}
else if (var6)
{
entity.extinguish();
}
}
player.addExhaustion(0.3F);
}
}
}
}
static void alertPlayerWolves(EntityPlayer player, EntityLiving living, boolean par2)
{
if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast))
{
if (living instanceof EntityWolf)
{
EntityWolf var3 = (EntityWolf)living;
if (var3.isTamed() && player.username.equals(var3.getOwnerName()))
{
return;
}
}
if (!(living instanceof EntityPlayer))// || player.isPVPEnabled()) //TODO: Find an alterntive for this
{
List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
Iterator var4 = var6.iterator();
while (var4.hasNext())
{
EntityWolf var5 = (EntityWolf)var4.next();
if (var5.isTamed() && var5.getEntityToAttack() == null && player.username.equals(var5.getOwnerName()) && (!par2 || !var5.isSitting()))
{
var5.setSitting(false);
var5.setTarget(living);
}
}
}
}
}
/* Tool specific */
public static void damageTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge)
{
@ -220,41 +443,8 @@ public class AbilityHelper
}
/* 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)
if (mob.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), attack))
{
damageTool(stack, 1, tags, player, false);
if (tags.getCompoundTag("InfiTool").getBoolean("Necrotic"))
player.heal(1);
}
else
mob.attackEntityFrom(DamageSource.causeMobDamage(player), attack);
if (tags.getCompoundTag("InfiTool").hasKey("Fiery"))
{
System.out.println("Fiery: "+tags.getInteger("Fiery"));
mob.setFire(tags.getCompoundTag("InfiTool").getInteger("Fiery")/5+1);
}
}
}
public static DamageSource causePiercingDamage (EntityLiving mob)
{

View File

@ -1,20 +1,23 @@
package tinker.tconstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import tinker.tconstruct.client.gui.ToolGuiElement;
import tinker.tconstruct.crafting.PatternBuilder;
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.PostInit;
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.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
@ -24,7 +27,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
* @author: mDiyo
*/
@Mod(modid = "TConstruct", name = "TConstruct", version = "Beta 3")
@Mod(modid = "TConstruct", name = "TConstruct", version = "mc1.4.7_1.0.3")
@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels={"TConstruct"}, packetHandler = tinker.tconstruct.TConstructPacketHandler.class)
public class TConstruct
{
@ -59,10 +62,21 @@ public class TConstruct
//GameRegistry.registerWorldGenerator(new TBaseWorldGenerator());
}
@PostInit
public void postInit(FMLPostInitializationEvent evt)
{
ArrayList<ItemStack> copperIngots = OreDictionary.getOres("ingotCopper");
for (ItemStack copper : copperIngots)
PatternBuilder.instance.registerMaterial(copper, 2, "copper");
ArrayList<ItemStack> bronzeIngots = OreDictionary.getOres("ingotBronze");
for (ItemStack bronze : bronzeIngots)
PatternBuilder.instance.registerMaterial(bronze, 2, "bronze");
}
@ForgeSubscribe
public void registerOre(OreRegisterEvent evt)
{
System.out.println("Ore event: "+evt.Name);
if (evt.Name == "battery")
content.modE.batteries.add(evt.Ore);
@ -130,8 +144,8 @@ public class TConstruct
//"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 versatile farming tool. It is effective on wood, dirt, and plants.\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- Wide 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- Hand 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 Longsword is a balanced weapon. It is useful for knocking enemies away or getting in and out of battle quickly.\n\nNatural Ability:\n- Charge Boost\nDamage: Moderate\nDurability: Moderate\n\nRequired parts:\n- Sword Blade\n- Hand 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\n- Charge Boost\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"
"The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\nSpecial Ability: Block\nDamage: Low\nDurability: Average\n\nRequired parts:\n- Sign Board\n- Handle"

View File

@ -186,7 +186,7 @@ public class TConstructContent
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(Item.dyePowder, 1, 0), new ItemStack(Item.bone), 5);
pb.registerFullMaterial(Item.bone, 2, "bone", new ItemStack(Item.dyePowder, 1, 15), new ItemStack(Item.bone), 5);
pb.registerFullMaterial(Block.obsidian, 2, "obsidian", 6);
pb.registerFullMaterial(Block.netherrack, 2, "netherrack", 7);
pb.registerFullMaterial(new ItemStack(materials, 1, 1), 2, "slime", new ItemStack(toolShard, 1, 8), new ItemStack(toolRod, 1, 8), 8);
@ -239,7 +239,10 @@ public class TConstructContent
ItemStack reBattery = ic2.api.Items.getItem("reBattery");
if (reBattery != null)
modE.batteries.add(new ItemStack(reBattery.getItem(), 1, -1));
modE.batteries.add(reBattery);
ItemStack chargedReBattery = ic2.api.Items.getItem("chargedReBattery");
if (chargedReBattery != null)
modE.batteries.add(new ItemStack(chargedReBattery.getItem(), 1, -1));
ItemStack electronicCircuit = ic2.api.Items.getItem("electronicCircuit");
if (electronicCircuit != null)
modE.circuits.add(electronicCircuit);

View File

@ -1,15 +1,12 @@
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;
import tinker.tconstruct.logic.FrypanLogic;
public class FrypanContainer extends Container
{

View File

@ -1,12 +1,12 @@
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;
import tinker.common.IPattern;
import tinker.tconstruct.logic.PartCrafterLogic;
import tinker.tconstruct.logic.PatternChestLogic;
public class PartCrafterChestContainer extends PartCrafterContainer
{
@ -18,7 +18,7 @@ public class PartCrafterChestContainer extends PartCrafterContainer
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),
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), 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]);
@ -49,14 +49,38 @@ public class PartCrafterChestContainer extends PartCrafterContainer
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
return null;
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()+patternLogic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
}

View File

@ -1,11 +1,12 @@
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;
import tinker.common.IPattern;
import tinker.tconstruct.logic.PartCrafterLogic;
public class PartCrafterContainer extends Container
{
@ -21,7 +22,7 @@ public class PartCrafterContainer extends Container
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),
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), 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]);
@ -49,9 +50,38 @@ public class PartCrafterContainer extends Container
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
//TODO: Shift-click override
return null;
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, 2, 4, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
}

View File

@ -49,7 +49,7 @@ public class PartCrafterGui extends GuiContainer
void drawMaterialInformation ()
{
ItemStack top = logic.getStackInSlot(1);
ItemStack top = logic.getStackInSlot(2);
ItemStack bottom = logic.getStackInSlot(3);
if (topMaterial != top)
{
@ -144,11 +144,11 @@ public class PartCrafterGui extends GuiContainer
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(1))
if (!logic.isStackInSlot(2))
{
this.drawTexturedModalRect(cornerX + 57, cornerY + 26, 176, 18, 18, 18);
}
if (!logic.isStackInSlot(2))
if (!logic.isStackInSlot(1))
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 44, 176, 0, 18, 18);
}

View File

@ -1,5 +1,6 @@
package tinker.tconstruct.client.gui;
import tinker.common.IPattern;
import tinker.tconstruct.logic.PatternChestLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -51,9 +52,10 @@ public class PatternChestContainer extends Container
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
@ -85,4 +87,13 @@ public class PatternChestContainer extends Container
return stack;
}
@Override
protected boolean mergeItemStack(ItemStack stack, int inventorySize, int slotSize, boolean par4)
{
if (!(stack.getItem() instanceof IPattern))
return false;
return super.mergeItemStack(stack, inventorySize, slotSize, par4);
}
}

View File

@ -78,9 +78,94 @@ public class ToolStationContainer extends Container
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i)
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
return null;
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())
{
System.out.println("Merging itemstack, true");
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory() - 1, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
/*@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
//this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
itemstack = slotStack.copy();
if (slotID == 0)
{
if (!mergeItemStack(slotStack, 4, 40, true)) //10 = size of crafting grid, 46 = total, 0 == output slot
{
return null;
}
}
else if (slotID >= 4 && slotID < 37)
{
if (!mergeItemStack(slotStack, 37, 40, false))
{
return null;
}
}
else if (slotID >= 37 && slotID < 40)
{
if (!mergeItemStack(slotStack, 4, 37, false))
{
return null;
}
}
else if (!mergeItemStack(slotStack, 4, 40, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (slotStack.stackSize != itemstack.stackSize)
{
slot.onPickupFromSlot(player, slotStack);
}
else
{
return null;
}
}
return itemstack;
}*/
}

View File

@ -315,13 +315,14 @@ public class ToolStationGui extends GuiContainer
this.mc.renderEngine.bindTexture(texID);
cornerX = (this.width + this.xSize) / 2;
cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize);
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30);
}
protected void keyTyped (char par1, int keyCode)
{
if (keyCode == 1)
{
logic.setToolname("");
updateServer("");
Keyboard.enableRepeatEvents(false);
this.mc.thePlayer.closeScreen();

View File

@ -121,7 +121,7 @@ public class ToolBuilder
modifiers += (head == 9 ? 1 : 0) + (handle == 9 ? 1 : 0) + (accessory == 9 ? 1 : 0);
compound.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers);
if (name != "" && name != null)
if (name != null && !name.equals(""))
{
compound.setCompoundTag("display", new NBTTagCompound());
compound.getCompoundTag("display").setString("Name", "\u00A7f" + name);

View File

@ -293,4 +293,13 @@ public class FrypanLogic extends EquipLogic
{
return new FrypanContainer(inventoryplayer, this);
}
/*@Override
public boolean canDropInventorySlot(int slot)
{
if (slot == 0)
return false;
else
return true;
}*/
}

View File

@ -57,7 +57,7 @@ public class PartCrafterLogic extends InventoryLogic
{
if (!craftedTop)
{
int value = PatternBuilder.instance.getPartValue(inventory[1]);
int value = PatternBuilder.instance.getPartValue(inventory[2]);
int cost = ((Pattern)inventory[0].getItem()).getPatternCost(inventory[0].getItemDamage());
if (value > 0)
{
@ -82,7 +82,7 @@ public class PartCrafterLogic extends InventoryLogic
if (!craftedBottom)
{
int value = PatternBuilder.instance.getPartValue(inventory[3]);
int cost = ((Pattern)inventory[2].getItem()).getPatternCost(inventory[2].getItemDamage());
int cost = ((Pattern)inventory[1].getItem()).getPatternCost(inventory[1].getItemDamage());
if (value > 0)
{
int decrease = cost / value;
@ -108,15 +108,15 @@ public class PartCrafterLogic extends InventoryLogic
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if ((slot == 0 || slot == 1) && !craftedTop)
if ((slot == 0 || slot == 2) && !craftedTop)
buildTopPart();
if ((slot == 2 || slot == 3) && !craftedBottom)
if ((slot == 1 || slot == 3) && !craftedBottom)
buildBottomPart();
}
void buildTopPart ()
{
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[1], inventory[0], inventory[2]);
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[2]);
if (parts != null)
{
inventory[4] = parts[0];
@ -130,7 +130,7 @@ public class PartCrafterLogic extends InventoryLogic
void buildBottomPart ()
{
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[2], inventory[0]);
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
if (parts != null)
{
inventory[6] = parts[0];

View File

@ -5,6 +5,7 @@ import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tinker.common.InventoryLogic;
import tinker.tconstruct.TConstructContent;
import tinker.tconstruct.client.gui.PatternShaperContainer;
public class PatternShaperLogic extends InventoryLogic
@ -26,11 +27,39 @@ public class PatternShaperLogic extends InventoryLogic
return new PatternShaperContainer(inventoryplayer, this);
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 0)
setInventorySlotContents(1, new ItemStack(TConstructContent.woodPattern, 1, 1));
}
@Override
public ItemStack decrStackSize(int slot, int quantity)
{
if (slot == 1)
{
super.decrStackSize(0, 1);
if (getStackInSlot(0) != null)
return super.decrStackSize(slot, 0);
}
else if (slot == 0)
{
ItemStack ret = super.decrStackSize(slot, quantity);
if (getStackInSlot(0) == null)
decrStackSize(1, 1);
return ret;
}
return super.decrStackSize(slot, quantity);
}
@Override
public boolean canDropInventorySlot(int slot)
{
if (slot == 0)
return true;
else
return false;
}
}

View File

@ -22,7 +22,7 @@ public class FryingPan extends Weapon
@Override
public boolean hitEntity(ItemStack stack, EntityLiving mob, EntityLiving player)
{
AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
//AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
AbilityHelper.knockbackEntity(mob, 1.7f);
mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 0)); //5 seconds of stun
//Play "thunk" sfx

View File

@ -20,10 +20,10 @@ public class Longsword extends Weapon
this.setItemName("InfiTool.Longsword");
}
public EnumAction getItemUseAction(ItemStack par1ItemStack)
/*public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.bow;
}
}*/
/*public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
@ -33,12 +33,17 @@ public class Longsword extends Weapon
return stack;
}*/
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
public float chargeAttack()
{
return 1.2f;
}
/*public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
{
if (time > 5)
AbilityHelper.thrust(stack, world, player);
player.swingItem();
}
}*/
@Override
protected Item getHeadItem ()

View File

@ -33,7 +33,7 @@ public class Rapier extends Weapon
@Override
public boolean hitEntity(ItemStack stack, EntityLiving mob, EntityLiving player)
{
AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
//AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
AbilityHelper.knockbackEntity(mob, 0.8f);
mob.motionY *= 0.5;
if (mob.hurtResistantTime > 16)
@ -45,6 +45,16 @@ public class Rapier extends Weapon
{
return 0.7f;
}
public float chargeAttack()
{
return 2f;
}
public boolean pierceArmor()
{
return true;
}
@Override
protected Item getHeadItem ()

View File

@ -8,6 +8,8 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
@ -17,6 +19,11 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.stats.AchievementList;
import net.minecraft.stats.StatList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import tinker.tconstruct.AbilityHelper;
@ -413,7 +420,8 @@ public abstract class ToolCore extends Item
@Override
public boolean hitEntity (ItemStack stack, EntityLiving mob, EntityLiving player)
{
AbilityHelper.hitEntity(stack, mob, player);
//AbilityHelper.hitEntity(stack, mob, player);
//AbilityHelper.damageTool(stack, 1, player, false);
return true;
}
@ -438,13 +446,25 @@ public abstract class ToolCore extends Item
return false;
}
//Complete override of attacking
/*public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
/* Attacking */
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
AbilityHelper.onLeftClickEntity(stack, player, entity, this);
return true;
}*/
}
public int getDamageVsEntity(Entity par1Entity)
public boolean pierceArmor()
{
return false;
}
public float chargeAttack()
{
return 1f;
}
public int getDamageVsEntity(Entity par1Entity) //Redundant
{
return this.damageVsEntity;
}