diff --git a/bin/minecraft/obsidian/ObsidianArrows.png b/bin/minecraft/obsidian/ObsidianArrows.png deleted file mode 100644 index 78bc25250..000000000 Binary files a/bin/minecraft/obsidian/ObsidianArrows.png and /dev/null differ diff --git a/bin/minecraft/obsidian/items.png b/bin/minecraft/obsidian/items.png index b9240e086..cb357cfe4 100644 Binary files a/bin/minecraft/obsidian/items.png and b/bin/minecraft/obsidian/items.png differ diff --git a/src/common/net/uberkat/obsidian/common/CommandOI.java b/src/common/net/uberkat/obsidian/common/CommandOI.java index e2388bdb3..47f49bacf 100644 --- a/src/common/net/uberkat/obsidian/common/CommandOI.java +++ b/src/common/net/uberkat/obsidian/common/CommandOI.java @@ -16,6 +16,11 @@ public class CommandOI extends CommandBase { return "oi"; } + + public String getCommandUsage(ICommandSender sender) + { + return "/oi "; + } public List getCommandAliases() { @@ -29,26 +34,54 @@ public class CommandOI extends CommandBase public void processCommand(ICommandSender sender, String[] params) { - if(params.length < 2) + if(params.length < 1) { sender.sendChatToPlayer(EnumColor.GREY.code + "-------- " + EnumColor.DARK_BLUE.code + "[ObsidianIngots]" + EnumColor.GREY.code + " --------"); sender.sendChatToPlayer(EnumColor.GREY.code + " *Version: " + EnumColor.DARK_GREY.code + ObsidianIngots.versionNumber); sender.sendChatToPlayer(EnumColor.GREY.code + " *Latest Version: " + EnumColor.DARK_GREY.code + ObsidianIngots.latestVersionNumber); sender.sendChatToPlayer(EnumColor.GREY.code + " *Developed on Mac OS X 10.8 Mountain Lion"); sender.sendChatToPlayer(EnumColor.GREY.code + " *Code, textures, and ideas by aidancbrady"); - sender.sendChatToPlayer(EnumColor.GREY.code + " *Recent News: " + EnumColor.DARK_BLUE + ObsidianIngots.recentNews); - sender.sendChatToPlayer(EnumColor.GREY.code + "-------- " + EnumColor.DARK_BLUE.code + "[==============]" + EnumColor.GREY.code + " --------"); + sender.sendChatToPlayer(EnumColor.GREY.code + " *Recent News: " + EnumColor.INDIGO.code + ObsidianIngots.recentNews); + sender.sendChatToPlayer(EnumColor.GREY.code + "-------- " + EnumColor.DARK_BLUE.code + "[============]" + EnumColor.GREY.code + " --------"); } - else if(params.length == 2 && params[1].equalsIgnoreCase("update")) + else if(params.length == 1) { - if(ObsidianUtils.isLatestVersion()) - { - sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots] " + EnumColor.GREY.code + "Obsidian Ingots is already up-to-date."); - } - else { - sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots] " + EnumColor.GREY.code + "Preparing to update..."); - new ThreadServerUpdate("http://dl.dropbox.com/u/90411166/ObsidianIngots.jar", sender); - } + if(params[0].equalsIgnoreCase("update")) + { + if(ObsidianUtils.isLatestVersion()) + { + sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots] " + EnumColor.GREY.code + "Obsidian Ingots is already up-to-date."); + } + else { + sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots] " + EnumColor.GREY.code + "Preparing to update..."); + new ThreadServerUpdate("http://dl.dropbox.com/u/90411166/ObsidianIngots.jar", sender); + } + } + + else if(params[0].equalsIgnoreCase("help")) + { + sender.sendChatToPlayer(EnumColor.GREY.code + "-------- " + EnumColor.DARK_BLUE.code + "[ObsidianIngots]" + EnumColor.GREY.code + " --------"); + sender.sendChatToPlayer(EnumColor.INDIGO.code + " /oi" + EnumColor.GREY.code + " -- displays the main page."); + sender.sendChatToPlayer(EnumColor.INDIGO.code + " /oi help" + EnumColor.GREY.code + " -- displays this guide."); + sender.sendChatToPlayer(EnumColor.INDIGO.code + " /oi update" + EnumColor.GREY.code + " -- updates the Obsidian Ingots server."); + sender.sendChatToPlayer(EnumColor.INDIGO.code + " /oi version" + EnumColor.GREY.code + " -- displays the version number."); + sender.sendChatToPlayer(EnumColor.INDIGO.code + " /oi news" + EnumColor.GREY.code + " -- displays most recent recent news."); + sender.sendChatToPlayer(EnumColor.GREY.code + "-------- " + EnumColor.DARK_BLUE.code + "[============]" + EnumColor.GREY.code + " --------"); + } + + else if(params[0].equalsIgnoreCase("version")) + { + sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots]" + EnumColor.GREY.code + " This server is running on version " + EnumColor.DARK_GREY.code + ObsidianIngots.versionNumber.toString() + EnumColor.GREY.code + "."); + } + + else if(params[0].equalsIgnoreCase("news")) + { + sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots]" + EnumColor.GREY.code + " Most recent news: " + EnumColor.INDIGO.code + ObsidianIngots.recentNews); + } + + else { + sender.sendChatToPlayer(EnumColor.DARK_BLUE.code + "[ObsidianIngots]" + EnumColor.GREY.code + " Unknown command. Type '" + EnumColor.INDIGO.code + "/oi help" + EnumColor.GREY.code + "' for help."); + } } } } diff --git a/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java b/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java index a7f833392..2b68032c4 100644 --- a/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java +++ b/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java @@ -28,9 +28,4 @@ public class DamageSourceObsidian extends EntityDamageSourceIndirect { return (new DamageSourceObsidian("weapon", entity, entity1)).setProjectile(); } - - public static DamageSource causeObsidianArrowDamage(EntityObsidianArrow arrow, Entity entity) - { - return (new EntityDamageSourceIndirect("arrow", arrow, entity)).setProjectile(); - } } diff --git a/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java b/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java deleted file mode 100644 index 06fa21dcd..000000000 --- a/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java +++ /dev/null @@ -1,526 +0,0 @@ -package net.uberkat.obsidian.common; - -import cpw.mods.fml.common.Side; -import cpw.mods.fml.common.asm.SideOnly; -import java.util.Iterator; -import java.util.List; -import net.minecraft.src.*; - -public class EntityObsidianArrow extends Entity -{ - private int xTile = -1; - private int yTile = -1; - private int zTile = -1; - private int inTile = 0; - private int inData = 0; - private boolean inGround = false; - - /** 1 if the player can pick up the arrow */ - public int canBePickedUp = 0; - - /** Seems to be some sort of timer for animating an arrow. */ - public int arrowShake = 0; - - /** The owner of this arrow. */ - public Entity shootingEntity; - private int ticksInGround; - private int ticksInAir = 0; - private double damage = 2.0D; - - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - - public EntityObsidianArrow(World par1World) - { - super(par1World); - this.setSize(0.5F, 0.5F); - } - - public EntityObsidianArrow(World par1World, double par2, double par4, double par6) - { - super(par1World); - this.setSize(0.5F, 0.5F); - this.setPosition(par2, par4, par6); - this.yOffset = 0.0F; - } - - public EntityObsidianArrow(World par1World, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving, float par4, float par5) - { - super(par1World); - this.shootingEntity = par2EntityLiving; - - if (par2EntityLiving instanceof EntityPlayer) - { - this.canBePickedUp = 1; - } - - this.posY = par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight() - 0.10000000149011612D; - double var6 = par3EntityLiving.posX - par2EntityLiving.posX; - double var8 = par3EntityLiving.posY + (double)par3EntityLiving.getEyeHeight() - 0.699999988079071D - this.posY; - double var10 = par3EntityLiving.posZ - par2EntityLiving.posZ; - double var12 = (double)MathHelper.sqrt_double(var6 * var6 + var10 * var10); - - if (var12 >= 1.0E-7D) - { - float var14 = (float)(Math.atan2(var10, var6) * 180.0D / Math.PI) - 90.0F; - float var15 = (float)(-(Math.atan2(var8, var12) * 180.0D / Math.PI)); - double var16 = var6 / var12; - double var18 = var10 / var12; - this.setLocationAndAngles(par2EntityLiving.posX + var16, this.posY, par2EntityLiving.posZ + var18, var14, var15); - this.yOffset = 0.0F; - float var20 = (float)var12 * 0.2F; - this.setArrowHeading(var6, var8 + (double)var20, var10, par4, par5); - } - } - - public EntityObsidianArrow(World par1World, EntityLiving par2EntityLiving, float par3) - { - super(par1World); - this.shootingEntity = par2EntityLiving; - - if (par2EntityLiving instanceof EntityPlayer) - { - this.canBePickedUp = 1; - } - - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); - this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); - this.posY -= 0.10000000149011612D; - this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); - this.setPosition(this.posX, this.posY, this.posZ); - this.yOffset = 0.0F; - this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); - this.setArrowHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); - } - - protected void entityInit() - { - this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); - } - - /** - * Uses the provided coordinates as a heading and determines the velocity from it with the set force and random - * variance. Args: x, y, z, force, forceVariation - */ - public void setArrowHeading(double par1, double par3, double par5, float par7, float par8) - { - float var9 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); - par1 /= (double)var9; - par3 /= (double)var9; - par5 /= (double)var9; - par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; - par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; - par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; - par1 *= (double)par7; - par3 *= (double)par7; - par5 *= (double)par7; - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - float var10 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)var10) * 180.0D / Math.PI); - this.ticksInGround = 0; - } - - @SideOnly(Side.CLIENT) - - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - - @SideOnly(Side.CLIENT) - - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double par1, double par3, double par5) - { - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)var7) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - super.onUpdate(); - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var1) * 180.0D / Math.PI); - } - - int var16 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); - - if (var16 > 0) - { - Block.blocksList[var16].setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); - AxisAlignedBB var2 = Block.blocksList[var16].getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); - - if (var2 != null && var2.isVecInside(Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) - { - this.inGround = true; - } - } - - if (this.arrowShake > 0) - { - --this.arrowShake; - } - - if (this.inGround) - { - int var18 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); - int var19 = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); - - if (var18 == this.inTile && var19 == this.inData) - { - ++this.ticksInGround; - - if (this.ticksInGround == 1200) - { - this.setDead(); - } - } - else - { - this.inGround = false; - this.motionX *= (double)(this.rand.nextFloat() * 0.2F); - this.motionY *= (double)(this.rand.nextFloat() * 0.2F); - this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); - this.ticksInGround = 0; - this.ticksInAir = 0; - } - } - else - { - ++this.ticksInAir; - Vec3 var17 = Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); - Vec3 var3 = Vec3.getVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition var4 = this.worldObj.rayTraceBlocks_do_do(var17, var3, false, true); - var17 = Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); - var3 = Vec3.getVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (var4 != null) - { - var3 = Vec3.getVec3Pool().getVecFromPool(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); - } - - Entity var5 = null; - List var6 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double var7 = 0.0D; - Iterator var9 = var6.iterator(); - float var11; - - while (var9.hasNext()) - { - Entity var10 = (Entity)var9.next(); - - if (var10.canBeCollidedWith() && (var10 != this.shootingEntity || this.ticksInAir >= 5)) - { - var11 = 0.3F; - AxisAlignedBB var12 = var10.boundingBox.expand((double)var11, (double)var11, (double)var11); - MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); - - if (var13 != null) - { - double var14 = var17.distanceTo(var13.hitVec); - - if (var14 < var7 || var7 == 0.0D) - { - var5 = var10; - var7 = var14; - } - } - } - } - - if (var5 != null) - { - var4 = new MovingObjectPosition(var5); - } - - float var20; - - if (var4 != null) - { - if (var4.entityHit != null) - { - var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - int var24 = MathHelper.ceiling_double_int((double)var20 * this.damage); - - if (this.func_70241_g()) - { - var24 += this.rand.nextInt(var24 / 2 + 2); - } - - DamageSource var22 = null; - - if (this.shootingEntity == null) - { - var22 = DamageSourceObsidian.causeObsidianArrowDamage(this, this); - } - else - { - var22 = DamageSourceObsidian.causeObsidianArrowDamage(this, this.shootingEntity); - } - - if (this.isBurning()) - { - var4.entityHit.setFire(5); - } - - if (var4.entityHit.attackEntityFrom(var22, var24)) - { - if (var4.entityHit instanceof EntityLiving) - { - ++((EntityLiving)var4.entityHit).arrowHitTempCounter; - - if (this.knockbackStrength > 0) - { - float var25 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (var25 > 0.0F) - { - var4.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)var25, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)var25); - } - } - } - - this.worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.setDead(); - } - else - { - this.motionX *= -0.10000000149011612D; - this.motionY *= -0.10000000149011612D; - this.motionZ *= -0.10000000149011612D; - this.rotationYaw += 180.0F; - this.prevRotationYaw += 180.0F; - this.ticksInAir = 0; - } - } - else - { - this.xTile = var4.blockX; - this.yTile = var4.blockY; - this.zTile = var4.blockZ; - this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); - this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); - this.motionX = (double)((float)(var4.hitVec.xCoord - this.posX)); - this.motionY = (double)((float)(var4.hitVec.yCoord - this.posY)); - this.motionZ = (double)((float)(var4.hitVec.zCoord - this.posZ)); - var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / (double)var20 * 0.05000000074505806D; - this.posY -= this.motionY / (double)var20 * 0.05000000074505806D; - this.posZ -= this.motionZ / (double)var20 * 0.05000000074505806D; - this.worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.arrowShake = 7; - this.func_70243_d(false); - } - } - - if (this.func_70241_g()) - { - for (int var21 = 0; var21 < 4; ++var21) - { - this.worldObj.spawnParticle("portal", this.posX + this.motionX * (double)var21 / 4.0D, this.posY + this.motionY * (double)var21 / 4.0D, this.posZ + this.motionZ * (double)var21 / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); - } - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - - for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var20) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) - { - ; - } - - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) - { - this.prevRotationPitch += 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw < -180.0F) - { - this.prevRotationYaw -= 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) - { - this.prevRotationYaw += 360.0F; - } - - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; - float var23 = 0.99F; - var11 = 0.05F; - - if (this.isInWater()) - { - for (int var26 = 0; var26 < 4; ++var26) - { - float var27 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)var27, this.posY - this.motionY * (double)var27, this.posZ - this.motionZ * (double)var27, this.motionX, this.motionY, this.motionZ); - } - - var23 = 0.8F; - } - - this.motionX *= (double)var23; - this.motionY *= (double)var23; - this.motionZ *= (double)var23; - this.motionY -= (double)var11; - this.setPosition(this.posX, this.posY, this.posZ); - this.doBlockCollisions(); - } - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) - { - par1NBTTagCompound.setShort("xTile", (short)this.xTile); - par1NBTTagCompound.setShort("yTile", (short)this.yTile); - par1NBTTagCompound.setShort("zTile", (short)this.zTile); - par1NBTTagCompound.setByte("inTile", (byte)this.inTile); - par1NBTTagCompound.setByte("inData", (byte)this.inData); - par1NBTTagCompound.setByte("shake", (byte)this.arrowShake); - par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); - par1NBTTagCompound.setByte("pickup", (byte)this.canBePickedUp); - par1NBTTagCompound.setDouble("damage", this.damage); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) - { - this.xTile = par1NBTTagCompound.getShort("xTile"); - this.yTile = par1NBTTagCompound.getShort("yTile"); - this.zTile = par1NBTTagCompound.getShort("zTile"); - this.inTile = par1NBTTagCompound.getByte("inTile") & 255; - this.inData = par1NBTTagCompound.getByte("inData") & 255; - this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; - this.inGround = par1NBTTagCompound.getByte("inGround") == 1; - - if (par1NBTTagCompound.hasKey("damage")) - { - this.damage = par1NBTTagCompound.getDouble("damage"); - } - - if (par1NBTTagCompound.hasKey("pickup")) - { - this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); - } - else if (par1NBTTagCompound.hasKey("player")) - { - this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; - } - } - - /** - * Called by a player entity when they collide with an entity - */ - public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) - { - if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) - { - boolean var2 = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; - - if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ObsidianIngots.ObsidianArrow, 1))) - { - var2 = false; - } - - if (var2) - { - this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - par1EntityPlayer.onItemPickup(this, 1); - this.setDead(); - } - } - } - - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - public void setDamage(double par1) - { - this.damage = par1; - } - - public double getDamage() - { - return this.damage; - } - - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int par1) - { - this.knockbackStrength = par1; - } - - /** - * If returns false, the item will not inflict any damage against entities. - */ - public boolean canAttackWithItem() - { - return false; - } - - public void func_70243_d(boolean par1) - { - byte var2 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(var2 | 1))); - } - else - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(var2 & -2))); - } - } - - public boolean func_70241_g() - { - byte var1 = this.dataWatcher.getWatchableObjectByte(16); - return (var1 & 1) != 0; - } -} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java b/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java index 00887e3ed..2e868f0e2 100644 --- a/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java @@ -12,17 +12,42 @@ public class ItemObsidianBow extends ItemObsidian setMaxDamage(750); setCreativeTab(CreativeTabs.tabCombat); } - - /** - * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount - */ - public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) + + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { - boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; + EntityPlayer player = (EntityPlayer)entity; + ItemStack currentItem = player.inventory.getCurrentItem(); - if (flag || par3EntityPlayer.inventory.hasItem(ObsidianIngots.ObsidianArrow.shiftedIndex)) + if (player.isUsingItem() && currentItem.itemID == ObsidianIngots.ObsidianBow.shiftedIndex) { - int i = getMaxItemUseDuration(par1ItemStack) - par4; + int useTicks = itemstack.getMaxItemUseDuration() - player.getItemInUseCount(); + + if (useTicks >= 14) + { + iconIndex = ObsidianIngots.BOW_TEXTURE_INDEX+3; + } + else if (useTicks > 9) + { + iconIndex = ObsidianIngots.BOW_TEXTURE_INDEX+2; + } + else if (useTicks > 0) + { + iconIndex = ObsidianIngots.BOW_TEXTURE_INDEX+1; + } + } + else + { + iconIndex = ObsidianIngots.BOW_TEXTURE_INDEX; + } + } + + public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer player, int itemUseCount) + { + boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemstack) > 0; + + if (flag || player.inventory.hasItem(Item.arrow.shiftedIndex)) + { + int i = getMaxItemUseDuration(itemstack) - itemUseCount; float f = (float)i / 20F; f = (f * f + f * 2.0F) / 3F; @@ -36,49 +61,57 @@ public class ItemObsidianBow extends ItemObsidian f = 1.0F; } - EntityObsidianArrow entityobsidianarrow = new EntityObsidianArrow(par2World, par3EntityPlayer, f * 2.0F); + EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F); if (f == 1.0F) { - entityobsidianarrow.func_70243_d(true); + entityarrow.func_70243_d(true); } - int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); + int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, itemstack); if (j > 0) { - entityobsidianarrow.setDamage(entityobsidianarrow.getDamage() + (double)j * 0.5D + 0.5D); + entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } - int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); + int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, itemstack); if (k > 0) { - entityobsidianarrow.setKnockbackStrength(k); + entityarrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, itemstack) > 0) { - entityobsidianarrow.setFire(100); + entityarrow.setFire(100); } - par1ItemStack.damageItem(1, par3EntityPlayer); - par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + itemstack.damageItem(1, player); + world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { - entityobsidianarrow.canBePickedUp = 2; + entityarrow.canBePickedUp = 2; } else { - par3EntityPlayer.inventory.consumeInventoryItem(ObsidianIngots.ObsidianArrow.shiftedIndex); + player.inventory.consumeInventoryItem(Item.arrow.shiftedIndex); } - if (!par2World.isRemote) + if (!world.isRemote) { - par2World.spawnEntityInWorld(entityobsidianarrow); + world.spawnEntityInWorld(entityarrow); + entityarrow.setFire(60); } } + + ItemStack itemStack = player.inventory.getCurrentItem(); + + if(itemStack.itemID != ObsidianIngots.ObsidianBow.shiftedIndex) + { + iconIndex = ObsidianIngots.BOW_TEXTURE_INDEX; + } } public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) @@ -86,28 +119,19 @@ public class ItemObsidianBow extends ItemObsidian return par1ItemStack; } - /** - * How long it takes to use or consume an item - */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 0x11940; } - /** - * returns the action that specifies what animation to play when the items is being used - */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - /** - * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer - */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ObsidianIngots.ObsidianArrow.shiftedIndex)) + if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex)) { par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); } @@ -115,9 +139,6 @@ public class ItemObsidianBow extends ItemObsidian return par1ItemStack; } - /** - * Return the enchantability factor of the item, most of the time is based on material. - */ public int getItemEnchantability() { return 1; diff --git a/src/common/net/uberkat/obsidian/common/ObsidianIngots.java b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java index 0d3d25ae9..b4ed0d38b 100644 --- a/src/common/net/uberkat/obsidian/common/ObsidianIngots.java +++ b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java @@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.TickRegistry; * @author AidanBrady * */ -@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.2.2") +@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.2.3") @NetworkMod(channels = { "ObsidianIngots" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class ObsidianIngots { @@ -60,7 +60,7 @@ public class ObsidianIngots public static Configuration configuration; /** Obsidian Ingots version number */ - public static Version versionNumber = new Version(4, 2, 2); + public static Version versionNumber = new Version(4, 2, 3); /** The latest version number which is received from the Obsidian Ingots server */ public static String latestVersionNumber; @@ -189,7 +189,6 @@ public class ObsidianIngots public static Item LazuliKnife; //Extra Items - public static Item ObsidianArrow; public static Item ObsidianBow; public static Item LightningRod; public static Item Stopwatch; @@ -218,6 +217,7 @@ public class ObsidianIngots public static int ticksPassed = 0; public static int ANIMATED_TEXTURE_INDEX = 240; + public static int BOW_TEXTURE_INDEX = 177; /** * Adds all in-game crafting and smelting recipes. @@ -466,9 +466,6 @@ public class ObsidianIngots GameRegistry.addRecipe(new ItemStack(ObsidianTNT, 1), new Object[] { "***", "XXX", "***", Character.valueOf('*'), Block.obsidian, Character.valueOf('X'), Block.tnt }); - GameRegistry.addRecipe(new ItemStack(ObsidianArrow, 8), new Object[] { - "A", "B", "C", Character.valueOf('A'), ObsidianIngot, Character.valueOf('B'), Item.stick, Character.valueOf('C'), Item.feather - }); GameRegistry.addRecipe(new ItemStack(ObsidianBow, 1), new Object[] { " AB", "A B", " AB", Character.valueOf('A'), ObsidianIngot, Character.valueOf('B'), Item.silk }); @@ -623,7 +620,6 @@ public class ObsidianIngots LanguageRegistry.addName(GlowstoneKnife, "Glowstone Knife"); //Extras - LanguageRegistry.addName(ObsidianArrow, "Obsidian Arrow"); LanguageRegistry.addName(ObsidianBow, "Obsidian Bow"); LanguageRegistry.addName(ObsidianTNT, "Obsidian TNT"); @@ -754,7 +750,6 @@ public class ObsidianIngots LazuliKnife.setIconIndex(208); //Extras - ObsidianArrow.setIconIndex(193); ObsidianBow.setIconIndex(177); if(extrasEnabled == true) @@ -818,7 +813,6 @@ public class ObsidianIngots LazuliBody = (new ItemObsidianArmor(11275, armorLAZULI, proxy.getArmorIndex("lazuli"), 1)).setItemName("LazuliBody"); LazuliLegs = (new ItemObsidianArmor(11276, armorLAZULI, proxy.getArmorIndex("lazuli"), 2)).setItemName("LazuliLegs"); LazuliBoots = (new ItemObsidianArmor(11277, armorLAZULI, proxy.getArmorIndex("lazuli"), 3)).setItemName("LazuliBoots"); - ObsidianArrow = new ItemObsidian(11278).setItemName("ObsidianArrow").setCreativeTab(CreativeTabs.tabCombat); ObsidianBow = new ItemObsidianBow(11279).setItemName("ObsidianBow"); if(extrasEnabled == true) { @@ -937,12 +931,10 @@ public class ObsidianIngots public void addEntities() { //Entity IDs - EntityRegistry.registerGlobalEntityID(EntityObsidianArrow.class, "ObsidianArrow", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityObsidianTNT.class, "ObsidianTNT", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityKnife.class, "Knife", EntityRegistry.findGlobalUniqueEntityId()); //Registrations - EntityRegistry.registerModEntity(EntityObsidianArrow.class, "ObsidianArrow", 50, this, 40, 5, true); EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 51, this, 40, 5, true); EntityRegistry.registerModEntity(EntityKnife.class, "Knife", 52, this, 40, 5, true); @@ -965,6 +957,13 @@ public class ObsidianIngots ServerCommandHandler.initialize(); } + @PreInit + public void preInit(FMLPreInitializationEvent event) + { + //Set the mod's configuration + configuration = new Configuration(event.getSuggestedConfigurationFile()); + } + @PostInit public void postInit(FMLPostInitializationEvent event) { @@ -974,11 +973,9 @@ public class ObsidianIngots System.out.println("[ObsidianIngots] Hooking complete."); } - @PreInit - public void preInit(FMLPreInitializationEvent event) + @Init + public void init(FMLInitializationEvent event) { - //Set the mod's configuration - configuration = new Configuration(event.getSuggestedConfigurationFile()); //Register the mod's ore handler GameRegistry.registerWorldGenerator(new OreHandler()); //Register the mod's GUI handler