diff --git a/src/main/java/tconstruct/armor/ArmorAbilities.java b/src/main/java/tconstruct/armor/ArmorAbilities.java index b6a5661f..a814cd01 100644 --- a/src/main/java/tconstruct/armor/ArmorAbilities.java +++ b/src/main/java/tconstruct/armor/ArmorAbilities.java @@ -1,14 +1,8 @@ package tconstruct.armor; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.List; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.IAttributeInstance; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -18,6 +12,9 @@ import tconstruct.armor.items.TravelGear; import tconstruct.armor.player.TPlayerStats; import tconstruct.library.modifier.IModifyable; import tconstruct.util.network.HealthUpdatePacket; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.common.gameevent.TickEvent; public class ArmorAbilities { @@ -45,7 +42,7 @@ public class ArmorAbilities //Feet changes ItemStack feet = player.getCurrentArmor(0); - if (feet != null) + if (feet != null && feet.hasTagCompound()) { if (feet.getItem() instanceof IModifyable && !player.isSneaking()) { diff --git a/src/main/java/tconstruct/armor/items/TravelWings.java b/src/main/java/tconstruct/armor/items/TravelWings.java index 53bfa001..bafe452a 100644 --- a/src/main/java/tconstruct/armor/items/TravelWings.java +++ b/src/main/java/tconstruct/armor/items/TravelWings.java @@ -1,6 +1,5 @@ package tconstruct.armor.items; -import cpw.mods.fml.relauncher.*; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -10,6 +9,8 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import tconstruct.library.armor.ArmorPart; import tconstruct.tools.TinkerTools; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class TravelWings extends TravelGear { @@ -38,22 +39,25 @@ public class TravelWings extends TravelGear public void onArmorTick (World world, EntityPlayer player, ItemStack itemStack) { super.onArmorTick(world, player, itemStack); - NBTTagCompound tag = itemStack.getTagCompound().getCompoundTag(getBaseTagName()); - int feather = tag.getInteger("Feather Fall"); - if (feather > 0) + if (itemStack.hasTagCompound()) { - if (player.fallDistance > 2.5) - player.fallDistance = 2.5f; - float terminalVelocity = -0.4f + (feather * 0.08f); - if (terminalVelocity > -0.05f) - terminalVelocity = -0.05f; - if (player.isSneaking() && terminalVelocity > -0.8f) - terminalVelocity = -0.8F; - boolean flying = false; - flying = player.capabilities.isFlying; - if (!flying && player.motionY < terminalVelocity) + NBTTagCompound tag = itemStack.getTagCompound().getCompoundTag(getBaseTagName()); + int feather = tag.getInteger("Feather Fall"); + if (feather > 0) { - player.motionY = terminalVelocity; + if (player.fallDistance > 2.5) + player.fallDistance = 2.5f; + float terminalVelocity = -0.4f + (feather * 0.08f); + if (terminalVelocity > -0.05f) + terminalVelocity = -0.05f; + if (player.isSneaking() && terminalVelocity > -0.8f) + terminalVelocity = -0.8F; + boolean flying = false; + flying = player.capabilities.isFlying; + if (!flying && player.motionY < terminalVelocity) + { + player.motionY = terminalVelocity; + } } } } diff --git a/src/main/java/tconstruct/items/tools/Battleaxe.java b/src/main/java/tconstruct/items/tools/Battleaxe.java index db60aa6a..fed3c85d 100644 --- a/src/main/java/tconstruct/items/tools/Battleaxe.java +++ b/src/main/java/tconstruct/items/tools/Battleaxe.java @@ -1,34 +1,35 @@ package tconstruct.items.tools; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.relauncher.*; -import mantle.world.WorldHelper; import mods.battlegear2.api.PlayerEventChild; import mods.battlegear2.api.weapons.IBattlegearWeapon; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.entity.*; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.*; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import tconstruct.library.*; -import tconstruct.library.tools.*; +import tconstruct.library.tools.AOEHarvestTool; +import tconstruct.library.tools.AbilityHelper; import tconstruct.tools.TinkerTools; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -@Optional.InterfaceList({ - @Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"), - @Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword") -}) +@Optional.InterfaceList({ @Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"), + @Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword") }) public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon { public Battleaxe() { - super(4, 1,1); + super(4, 1, 1); this.setUnlocalizedName("InfiTool.Battleaxe"); } @@ -181,10 +182,14 @@ public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon int boost = time / 100; if (boost > 2) boost = 2; - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost)); - player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost)); - player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0)); - player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0)); + + if (!world.isRemote) + { + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost)); + player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost)); + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0)); + player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0)); + } if (time > 5 && player.onGround) { player.addExhaustion(0.2F); @@ -239,45 +244,51 @@ public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon @Override @Optional.Method(modid = "battlegear2") - public boolean sheatheOnBack(ItemStack item) + public boolean sheatheOnBack (ItemStack item) { return true; } @Override @Optional.Method(modid = "battlegear2") - public boolean isOffhandHandDual(ItemStack off) { + public boolean isOffhandHandDual (ItemStack off) + { return true; } @Override @Optional.Method(modid = "battlegear2") - public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) { + public boolean offhandAttackEntity (PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) + { return true; } @Override @Optional.Method(modid = "battlegear2") - public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) { + public boolean offhandClickAir (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) + { return true; } @Override @Optional.Method(modid = "battlegear2") - public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) { + public boolean offhandClickBlock (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) + { return true; } @Override @Optional.Method(modid = "battlegear2") - public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) { + public void performPassiveEffects (Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) + { // unused } @Override @Optional.Method(modid = "battlegear2") - public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) { - if(offhand == null) + public boolean allowOffhand (ItemStack mainhand, ItemStack offhand) + { + if (offhand == null) return true; return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe) diff --git a/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java b/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java index 7e65adf6..0b6383bd 100644 --- a/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java +++ b/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java @@ -1,39 +1,36 @@ package tconstruct.library.weaponry; -import cpw.mods.fml.common.Optional; -import net.minecraft.init.Items; -import net.minecraft.util.StatCollector; -import tconstruct.client.TProxyClient; -import tconstruct.library.TConstructRegistry; -import tconstruct.weaponry.TinkerWeaponry; -import tconstruct.weaponry.ammo.ArrowAmmo; -import tconstruct.weaponry.ammo.BoltAmmo; -import tconstruct.weaponry.client.CrosshairType; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.ArrowLooseEvent; -import tconstruct.library.tools.AbilityHelper; -import tconstruct.library.tools.ToolCore; -import tconstruct.library.util.TextureHelper; -import tconstruct.tools.TinkerTools; -import tconstruct.weaponry.entity.ArrowEntity; -import mods.battlegear2.api.PlayerEventChild; -import mods.battlegear2.api.weapons.IBattlegearWeapon; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - import java.util.HashMap; import java.util.List; import java.util.Map; +import mods.battlegear2.api.PlayerEventChild; +import mods.battlegear2.api.weapons.IBattlegearWeapon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import tconstruct.client.TProxyClient; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.util.TextureHelper; +import tconstruct.tools.TinkerTools; +import tconstruct.weaponry.TinkerWeaponry; +import tconstruct.weaponry.client.CrosshairType; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @Optional.InterfaceList({ @Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon") }) @@ -132,8 +129,12 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe public float getProjectileSpeed(ItemStack itemStack) { - NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool"); - return toolTag.getFloat("FlightSpeed"); + if (itemStack != null && itemStack.hasTagCompound()) + { + NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool"); + return toolTag.getFloat("FlightSpeed"); + } + return 0; } /* Bow usage */ @@ -166,6 +167,11 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe @Override public void onPlayerStoppedUsing (ItemStack weapon, World world, EntityPlayer player, int useRemaining) { + if (!weapon.hasTagCompound()) + { + return; + } + int time = this.getMaxItemUseDuration(weapon) - useRemaining; // we abuse the arrowLooseEvent for all projectiles @@ -244,7 +250,10 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe @Override public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + NBTTagCompound tags = null; + + if(stack.hasTagCompound()) + tags = stack.getTagCompound().getCompoundTag("InfiTool"); if(tags == null || renderPass > 10) return super.getIcon(stack, renderPass, player, usingItem, useRemaining);