From 4fb70de8a8bc7fc54e905ab01f50f9e9569af50e Mon Sep 17 00:00:00 2001 From: mDiyo Date: Sat, 13 Apr 2013 08:48:19 -0700 Subject: [PATCH] Lapis Change --- mods/tinker/common/ToolMod.java | 4 +- mods/tinker/tconstruct/TConstruct.java | 2 +- mods/tinker/tconstruct/TContent.java | 4 +- .../tinker/tconstruct/container/SlotTool.java | 4 +- .../tconstruct/entity/UnstableCreeper.java | 167 +++++++++--------- .../tconstruct/library/HarvestTool.java | 2 + mods/tinker/tconstruct/library/ToolCore.java | 24 ++- mods/tinker/tconstruct/library/Weapon.java | 8 + .../tinker/tconstruct/modifiers/ModLapis.java | 112 +++++++++--- mods/tinker/tconstruct/tools/Rapier.java | 2 +- 10 files changed, 210 insertions(+), 119 deletions(-) diff --git a/mods/tinker/common/ToolMod.java b/mods/tinker/common/ToolMod.java index 0996b538..01e77b41 100644 --- a/mods/tinker/common/ToolMod.java +++ b/mods/tinker/common/ToolMod.java @@ -3,6 +3,7 @@ package mods.tinker.common; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Random; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -11,7 +12,8 @@ public abstract class ToolMod { public final String key; public final List stacks; - public final int effectIndex; //255 is always blank + public final int effectIndex; + public static Random random = new Random(); public ToolMod(ItemStack[] items, int effect, String dataKey) { diff --git a/mods/tinker/tconstruct/TConstruct.java b/mods/tinker/tconstruct/TConstruct.java index f55ab2d1..6a2f75c6 100644 --- a/mods/tinker/tconstruct/TConstruct.java +++ b/mods/tinker/tconstruct/TConstruct.java @@ -23,7 +23,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry; * @author: mDiyo */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.2.28.7") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.2.28.9") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.TPacketHandler.class) public class TConstruct { diff --git a/mods/tinker/tconstruct/TContent.java b/mods/tinker/tconstruct/TContent.java index b791456e..63c5ea7c 100644 --- a/mods/tinker/tconstruct/TContent.java +++ b/mods/tinker/tconstruct/TContent.java @@ -173,6 +173,7 @@ public class TContent implements IFuelHandler //Tool modifiers public static ModElectric modE; + public static ModLapis modL; //Golems public static Block glowSapling; @@ -533,7 +534,8 @@ public class TContent implements IFuelHandler ItemStack lapisItem = new ItemStack(Item.dyePowder, 1, 4); ItemStack lapisBlock = new ItemStack(Block.blockLapis); - tb.registerToolMod(new ModLapis(new ItemStack[] { lapisItem }, 10, 1)); + modL = new ModLapis(new ItemStack[] { lapisItem }, 10, 1); + tb.registerToolMod(modL); tb.registerToolMod(new ModLapis(new ItemStack[] { lapisItem, lapisItem }, 10, 2)); tb.registerToolMod(new ModLapis(new ItemStack[] { lapisBlock }, 10, 9)); tb.registerToolMod(new ModLapis(new ItemStack[] { lapisItem, lapisBlock }, 10, 10)); diff --git a/mods/tinker/tconstruct/container/SlotTool.java b/mods/tinker/tconstruct/container/SlotTool.java index f223c209..1d5e8f0b 100644 --- a/mods/tinker/tconstruct/container/SlotTool.java +++ b/mods/tinker/tconstruct/container/SlotTool.java @@ -26,8 +26,8 @@ public class SlotTool extends Slot */ public boolean isItemValid(ItemStack stack) { - //return false; - return stack.getItem() instanceof ToolCore; + return false; + //return stack.getItem() instanceof ToolCore; } public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack stack) diff --git a/mods/tinker/tconstruct/entity/UnstableCreeper.java b/mods/tinker/tconstruct/entity/UnstableCreeper.java index 55d9d36e..d6c988ba 100644 --- a/mods/tinker/tconstruct/entity/UnstableCreeper.java +++ b/mods/tinker/tconstruct/entity/UnstableCreeper.java @@ -6,114 +6,119 @@ import net.minecraft.world.World; public class UnstableCreeper extends EntityCreeper { - protected int fuseTime = 12; - protected int timeSinceIgnited; - protected int lastActiveTime; + protected int fuseTime = 12; + protected int timeSinceIgnited; + protected int lastActiveTime; - protected float explosionRadius = 1.5f; + public float explosionRadius = 1f; - public UnstableCreeper(World world) - { - super(world); + public UnstableCreeper(World world) + { + super(world); this.texture = "/mods/tinker/textures/mob/creeperunstable.png"; - } - - public int getMaxHealth() + } + + public int getMaxHealth () { return 12; } - protected void fall (float distance) - { - if (!this.worldObj.isRemote && distance > 3) - { - boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); + protected void fall (float distance) + { + if (!this.worldObj.isRemote) + { + if (distance > 5) + { + boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); - if (this.getPowered()) - { - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 0.75f * (worldObj.difficultySetting-1))* 2, false); - } - else - { - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 0.75f * (worldObj.difficultySetting-1)), false); - } + if (this.getPowered()) + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (0.75f * (worldObj.difficultySetting - 1)) * 2, false); + } + else + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (0.75f * (worldObj.difficultySetting - 1)), false); + } - this.setDead(); - } - } + this.setDead(); + } + else + super.fall(distance); + } + } - public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound) - { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setShort("Fuse", (short) this.fuseTime); - } + public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("Fuse", (short) this.fuseTime); + } - public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound) - { - super.readEntityFromNBT(par1NBTTagCompound); + public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); - if (par1NBTTagCompound.hasKey("Fuse")) - { - this.fuseTime = par1NBTTagCompound.getShort("Fuse"); - } - } + if (par1NBTTagCompound.hasKey("Fuse")) + { + this.fuseTime = par1NBTTagCompound.getShort("Fuse"); + } + } - public void onUpdate () - { - if (this.isEntityAlive()) - { - this.lastActiveTime = this.timeSinceIgnited; - int i = this.getCreeperState(); + public void onUpdate () + { + if (this.isEntityAlive()) + { + this.lastActiveTime = this.timeSinceIgnited; + int i = this.getCreeperState(); - if (i > 0 && this.timeSinceIgnited == 0) - { - this.playSound("random.fuse", 1.0F, 0.5F); - } + if (i > 0 && this.timeSinceIgnited == 0) + { + this.playSound("random.fuse", 1.0F, 0.5F); + } - this.timeSinceIgnited += i; + this.timeSinceIgnited += i; - if (this.timeSinceIgnited < 0) - { - this.timeSinceIgnited = 0; - } + if (this.timeSinceIgnited < 0) + { + this.timeSinceIgnited = 0; + } - if (this.timeSinceIgnited >= this.fuseTime) - { - this.timeSinceIgnited = this.fuseTime; + if (this.timeSinceIgnited >= this.fuseTime) + { + this.timeSinceIgnited = this.fuseTime; - if (!this.worldObj.isRemote) - { - boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); + if (!this.worldObj.isRemote) + { + boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); - if (this.getPowered()) - { - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 0.75f * (worldObj.difficultySetting-1))* 2, flag); - } - else - { - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 0.75f * (worldObj.difficultySetting-1)), flag); - } + if (this.getPowered()) + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 1f * (worldObj.difficultySetting - 1)) * 2, flag); + } + else + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (this.explosionRadius + 1f * (worldObj.difficultySetting - 1)), flag); + } - this.setDead(); - } - } - } + this.setDead(); + } + } + } - super.onUpdate(); - } + super.onUpdate(); + } - public float getCreeperFlashIntensity (float par1) - { - return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * par1) / (float) (this.fuseTime - 2); - } - - protected void dropFewItems(boolean par1, int par2) + public float getCreeperFlashIntensity (float par1) + { + return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * par1) / (float) (this.fuseTime - 2); + } + + protected void dropFewItems (boolean par1, int par2) { int j = this.getDropItemId(); if (j > 0) { - int k = this.rand.nextInt(3)+3; + int k = this.rand.nextInt(3) + 3; if (par2 > 0) { diff --git a/mods/tinker/tconstruct/library/HarvestTool.java b/mods/tinker/tconstruct/library/HarvestTool.java index ddf81cb4..6ed2d0a1 100644 --- a/mods/tinker/tconstruct/library/HarvestTool.java +++ b/mods/tinker/tconstruct/library/HarvestTool.java @@ -1,5 +1,6 @@ package mods.tinker.tconstruct.library; +import mods.tinker.tconstruct.TContent; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -23,6 +24,7 @@ public abstract class HarvestTool extends ToolCore @Override public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + TContent.modL.midStreamModify(stack); NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); World world = player.worldObj; int bID = player.worldObj.getBlockId(x, y, z); diff --git a/mods/tinker/tconstruct/library/ToolCore.java b/mods/tinker/tconstruct/library/ToolCore.java index 6e55fb06..e7fd9739 100644 --- a/mods/tinker/tconstruct/library/ToolCore.java +++ b/mods/tinker/tconstruct/library/ToolCore.java @@ -569,32 +569,40 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox * Every tool can be an electric tool if you modify it right */ @Override - public boolean canBeStoredInToolbox (ItemStack itemstack) + public boolean canBeStoredInToolbox (ItemStack stack) { return true; } @Override - public boolean canProvideEnergy (ItemStack itemStack) + public boolean canProvideEnergy (ItemStack stack) { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return false; + return true; } @Override - public int getChargedItemId (ItemStack itemStack) + public int getChargedItemId (ItemStack stack) { return this.itemID; } @Override - public int getEmptyItemId (ItemStack itemStack) + public int getEmptyItemId (ItemStack stack) { return this.itemID; } @Override - public int getMaxCharge (ItemStack itemStack) + public int getMaxCharge (ItemStack stack) { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + return 10000; } @@ -605,8 +613,12 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox } @Override - public int getTransferLimit (ItemStack itemStack) + public int getTransferLimit (ItemStack stack) { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + return 32; } diff --git a/mods/tinker/tconstruct/library/Weapon.java b/mods/tinker/tconstruct/library/Weapon.java index c44f9c03..2adf9169 100644 --- a/mods/tinker/tconstruct/library/Weapon.java +++ b/mods/tinker/tconstruct/library/Weapon.java @@ -1,7 +1,9 @@ package mods.tinker.tconstruct.library; +import mods.tinker.tconstruct.TContent; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; @@ -89,6 +91,12 @@ public abstract class Weapon extends ToolCore { return 1; } + + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) + { + TContent.modL.midStreamModify(stack); + return super.onLeftClickEntity(stack, player, entity); + } public static Material[] web = new Material[] { Material.web }; public static Material[] none = new Material[0]; diff --git a/mods/tinker/tconstruct/modifiers/ModLapis.java b/mods/tinker/tconstruct/modifiers/ModLapis.java index c04015fd..f79279d0 100644 --- a/mods/tinker/tconstruct/modifiers/ModLapis.java +++ b/mods/tinker/tconstruct/modifiers/ModLapis.java @@ -15,14 +15,13 @@ public class ModLapis extends ToolMod { String tooltipName; int increase; - int max; + int max = 450; public ModLapis(ItemStack[] items, int effect, int inc) { super(items, effect, "Lapis"); tooltipName = "\u00a79Luck"; increase = inc; - max = 100; } @Override @@ -33,7 +32,7 @@ public class ModLapis extends ToolMod return tags.getInteger("Modifiers") > 0; int keyPair[] = tags.getIntArray(key); - if (keyPair[0] + increase <= 100) + if (keyPair[0] + increase <= max) return true; else return false; @@ -46,43 +45,104 @@ public class ModLapis extends ToolMod if (!tags.hasKey(key)) { tags.setBoolean(key, true); - - String modName = "\u00a79Lapis (0/100)"; + + String modName = "\u00a79Lapis (0/450)"; int tooltipIndex = addToolTip(tool, "\u00a79Luck", modName); int[] keyPair = new int[] { 0, tooltipIndex }; tags.setIntArray(key, keyPair); - + int modifiers = tags.getInteger("Modifiers"); modifiers -= 1; tags.setInteger("Modifiers", modifiers); } - + int keyPair[] = tags.getIntArray(key); keyPair[0] += increase; tags.setIntArray(key, keyPair); if (tool.getItem() instanceof Weapon) { - if (keyPair[0] >= 100) + if (keyPair[0] >= 450) addEnchantment(tool, Enchantment.looting, 3); - else if (keyPair[0] >= 50) + else if (keyPair[0] >= 300) addEnchantment(tool, Enchantment.looting, 2); - else if (keyPair[0] >= 20) + else if (keyPair[0] >= 100) addEnchantment(tool, Enchantment.looting, 1); } else { - if (keyPair[0] >= 100) + if (keyPair[0] >= 450) addEnchantment(tool, Enchantment.fortune, 3); - else if (keyPair[0] >= 50) + else if (keyPair[0] >= 300) addEnchantment(tool, Enchantment.fortune, 2); - else if (keyPair[0] >= 20) + else if (keyPair[0] >= 100) addEnchantment(tool, Enchantment.fortune, 1); } - + updateModTag(tool, keyPair); } - - public void addEnchantment(ItemStack tool, Enchantment enchant, int level) + + public void midStreamModify (ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] == max) + return; + + if (random.nextInt(50) == 0) + { + keyPair[0] += 1; + tags.setIntArray(key, keyPair); + updateModTag(tool, keyPair); + } + + if (tool.getItem() instanceof Weapon) + { + if (keyPair[0] >= 350) + { + int chance = keyPair[0] - 300; + if (random.nextInt(1000 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 3); + } + else if (keyPair[0] >= 125) + { + int chance = keyPair[0] - 175; + if (random.nextInt(600 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 2); + } + else if (keyPair[0] >= 10) + { + int chance = keyPair[0] - 25; + if (random.nextInt(250 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 1); + } + } + else + { + if (keyPair[0] >= 350) + { + int chance = keyPair[0] - 300; + if (random.nextInt(1000 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 3); + } + else if (keyPair[0] >= 125) + { + int chance = keyPair[0] - 175; + if (random.nextInt(600 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 2); + } + else if (keyPair[0] >= 10) + { + int chance = keyPair[0] - 25; + if (random.nextInt(250 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 1); + } + } + } + + public void addEnchantment (ItemStack tool, Enchantment enchant, int level) { NBTTagList tags = new NBTTagList("ench"); Map enchantMap = EnchantmentHelper.getEnchantments(tool); @@ -93,37 +153,37 @@ public class ModLapis extends ToolMod while (iterator.hasNext()) { NBTTagCompound enchantTag = new NBTTagCompound(); - index = ((Integer)iterator.next()).intValue(); + 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)); + 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)); + 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)); + enchantTag.setShort("id", (short) enchant.effectId); + enchantTag.setShort("lvl", (short) ((byte) level)); tags.appendTag(enchantTag); } tool.stackTagCompound.setTag("ench", tags); } - + void updateModTag (ItemStack tool, int[] keys) { NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); - String tip = "ModifierTip"+keys[1]; - String modName = "\u00a79Lapis ("+keys[0]+"/100)"; + String tip = "ModifierTip" + keys[1]; + String modName = "\u00a79Lapis (" + keys[0] + "/" + max + ")"; tags.setString(tip, modName); } } diff --git a/mods/tinker/tconstruct/tools/Rapier.java b/mods/tinker/tconstruct/tools/Rapier.java index 31dd8a18..83612252 100644 --- a/mods/tinker/tconstruct/tools/Rapier.java +++ b/mods/tinker/tconstruct/tools/Rapier.java @@ -29,7 +29,7 @@ public class Rapier extends Weapon { if (player.onGround) { - player.addExhaustion(0.2f); + player.addExhaustion(0.1f); player.motionY += 0.32; float f = 0.5F; player.motionX = (double) (MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * f);