perromercenary00
Members-
Posts
849 -
Joined
-
Last visited
-
Days Won
5
Everything posted by perromercenary00
-
dude the entity arrow alredy has code for thath. 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 pieze of code causes the arrow to spaw at 0.16 mtrs to the rigth of the entity shooter
-
good days, i found an anoying bug in mod that can fuckup a whole world java.lang.NullPointerException: Ticking entity at mercenarymod.items.armasdefuego.balas.bala76239mm_entity.func_70071_h_(bala76239mm_entity.java:407) at net.minecraft.world.World.func_72866_a(World.java:1880) at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:732) at net.minecraft.world.World.func_72870_g(World.java:1850) at net.minecraft.world.World.func_72939_s(World.java:1679) at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:571) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:704) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:598) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:164) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:478) at java.lang.Thread.run(Thread.java:745) this is one bullet form mi mod this happen coz this bullet wasn't inside an entity or in the ground in the moment i close the game. for this to not happen again i need to make this bullet to die, or not to be save in the world on close how could i make this trick ??
-
good nigths i been working in some armours for mi mod and have some armour i whish to have diferent texture if wear by alex than wen is wear by steve, ¿is way to check if if ( playerModel == steve ){} well the other thing is when i wana change the player skin i just take some resource pack, unpackit and overwrite the steve.png skin whith the one i want, then in minecraft i select that resource pack and buala the player skin has change i whish to now is if is posible to force this new skin texture over the player but controled inside the mod whithout messing whit resourcepacks or trics well thanks
-
[1.8] Armor tutorials for 1.8 ??? <Solved>
perromercenary00 replied to perromercenary00's topic in Modder Support
i suer it wass not working before. but now is working perfect and dunot know wi the materials thing wass a long time ago java missunderstand error -
good days im not english speaker, i wanna add some custom armors to mi actual mod http://www.curse.com/mc-mods/minecraft/228033-mercenarymod and wanna make this custome armors able to resist mi custom grenades but leave thats for latter very confused im whith the tutorials, all i found is for 1.7 and the imports at the beginning of the class marks errors in eclipse thos classes dont exist anymore in 1.8 http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-7/custom-armor/ http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571540-1-7-x-1-8-forge-making-custom-armor-that-adds this kind of declaration works no more public static EnumArmorMaterial MYHTRIL= EnumHelper.addArmorMaterial("MYHTRIL", 47, new int[]{6, 10, 8, 6}, 28); but i learn in the forums this and do this wat the declarations for mi materials //coal public static ArmorMaterial car = EnumHelper.addArmorMaterial("car", "carbono", 12, new int[] {2, 6, 4, 2}, 16); public static ArmorMaterial carbono() { return car; } //steel public static ArmorMaterial ace = EnumHelper.addArmorMaterial("ace", "acero", 16, new int[] {3, 7, 5, 3}, 30); public static ArmorMaterial acero() { return ace; } //obsidian public static ArmorMaterial obs = EnumHelper.addArmorMaterial("obs", "obsidiana", 20, new int[] {4, 8, 6, 4}, 30); public static ArmorMaterial obsidiana() { return obs; } //bedrock public static ArmorMaterial nok = EnumHelper.addArmorMaterial("nok", "nokia", 30, new int[] {10, 10, 10, 10}, 60); public static ArmorMaterial nokia() { return nok; } well I need a tutorial update to 1.8 or at least the class code for a full armor whith the renders parts and the boots, helmet, chest, and pants classes Gracias.
-
hard hot fix aplied im deside to use the arrow datawachers to store the position and rotation values in the server side, later in the local side force them on the local arrow , is funny coz you almos could see how the misguided arrow change in the middle air towars the rigth direcction , is a visual bug but is tolerable main class @EventHandler public void preInit(FMLPreInitializationEvent event) { registrarBala( mercenarymod.items.arcos.flechaMercenaria_entity.class , "flechaMercenaria"); } //registrar entidad public static void registrarBala(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 20000, true); } full code package mercenarymod.items.arcos; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class flechaMercenaria_entity extends Entity implements IProjectile //EntityThrowable { //extend EntityThrowable/RenderThrowable private int xTile = -1; private int yTile = -1; private int zTile = -1; private Block inTile; private int inData; private boolean inGround; /** 1 if the player can pick up the arrow */ public int canBePickedUp; /** Seems to be some sort of timer for animating an arrow. */ public int arrowShake; /** The owner of this arrow. */ public Entity shootingEntity; private int ticksInGround; private int ticksInAir; private double damage = 2.0D; /** The amount of knockback an arrow applies when it hits a mob. */ private int knockbackStrength; private int updatetick = 0; private static final String __OBFID = "CL_00001715"; public flechaMercenaria_entity(World worldIn) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); } public flechaMercenaria_entity(World worldIn, double x, double y, double z) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); this.setPosition(x, y, z); } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D; double d0 = p_i1755_3_.posX - shooter.posX; double d1 = p_i1755_3_.getEntityBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY; double d2 = p_i1755_3_.posZ - shooter.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); double d4 = d0 / d3; double d5 = d2 / d3; this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3); float f4 = (float)(d3 * 0.20000000298023224D); this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_); } } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, float p_i1756_3_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.setSize(0.5F, 0.5F); this.setLocationAndAngles(shooter.posX , shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ , shooter.rotationYaw, shooter.rotationPitch); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * ((float)Math.PI) ) * 0.16F);//((float)Math.PI * 2 )m 0.16 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.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.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 0.0F); } protected void entityInit() { this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); this.dataWatcher.addObject(17, 0.0F ); // this.posX this.dataWatcher.addObject(18, 0.0F ); // this.posY this.dataWatcher.addObject(19, 0.0F ); // this.posZ this.dataWatcher.addObject(20, 0.0F ); // this.rotationPitch this.dataWatcher.addObject(21, 0.0F ); // this.rotationYaw this.dataWatcher.addObject(22, 0.0F ); // this.prevRotationPitch this.dataWatcher.addObject(23, 0.0F ); // this.prevRotationYaw //(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch) } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. * * @param inaccuracy Higher means more error. */ public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { float f2 = MathHelper.sqrt_double(x * x + y * y + z * z); x /= (double)f2; y /= (double)f2; z /= (double)f2; x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; x *= (double)velocity; y *= (double)velocity; z *= (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f3 = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); this.ticksInGround = 0; } @SideOnly(Side.CLIENT) public void func_180426_a(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_, int p_180426_9_, boolean p_180426_10_) { this.setPosition(p_180426_1_, p_180426_3_, p_180426_5_); this.setRotation(p_180426_7_, p_180426_8_); } /** * Sets the velocity to the args. Args: x, y, z */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 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(); //update position and rotation every tick for the first 5 , then once every 20 ticks or one second if( (updatetick < 5) | ((updatetick % 20) == 0) ) { if(!this.worldObj.isRemote) { this.dataWatcher.updateObject(17, (float)this.posX ); // this.posX this.dataWatcher.updateObject(18, (float)this.posY ); // this.posY this.dataWatcher.updateObject(19, (float)this.posZ ); // this.posZ this.dataWatcher.updateObject(20, (float)this.rotationPitch ); // this.rotationPitch this.dataWatcher.updateObject(21, (float)this.rotationYaw ); // this.rotationYaw this.dataWatcher.updateObject(22, (float)this.prevRotationPitch ); // this.prevRotationPitch this.dataWatcher.updateObject(23, (float)this.prevRotationYaw ); // this.prevRotationYaw } else { this.posX = this.dataWatcher.getWatchableObjectFloat(17); // this.posX this.posY = this.dataWatcher.getWatchableObjectFloat(18); // this.posY this.posZ = this.dataWatcher.getWatchableObjectFloat(19); // this.posZ this.rotationPitch = this.dataWatcher.getWatchableObjectFloat(20); // this.rotationPitch this.rotationYaw = this.dataWatcher.getWatchableObjectFloat(21); // this.rotationYaw this.prevRotationPitch = this.dataWatcher.getWatchableObjectFloat(22); // this.rotationPitch this.prevRotationYaw = this.dataWatcher.getWatchableObjectFloat(23); // this.rotationYaw } // System.out.println(updatetick +" #world="+this.worldObj.isRemote+" "+" X="+this.posX+" Y="+this.posY+" Z="+this.posZ+" RP="+this.rotationPitch+" RY="+ this.rotationYaw ); } updatetick ++; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = 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)f) * 180.0D / Math.PI); } BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); Block block = iblockstate.getBlock(); if (block.getMaterial() != Material.air) { block.setBlockBoundsBasedOnState(this.worldObj, blockpos); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, blockpos, iblockstate); if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.arrowShake > 0) { --this.arrowShake; } if (this.inGround) { int j = block.getMetaFromState(iblockstate); if (block == this.inTile && j == 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 vec31 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false); vec31 = new Vec3(this.posX, this.posY, this.posZ); vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int i; float f1; for (i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, (double)f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d1 = vec31.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) { movingobjectposition = null; } } float f2; float f3; float f4; if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int k = MathHelper.ceiling_double_int((double)f2 * this.damage); if (this.getIsCritical()) { k += this.rand.nextInt(k / 2 + 2); } DamageSource damagesource; if (this.shootingEntity == null) { damagesource = DamageSource.causeThrownDamage(this, this); } else { damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity); } if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { movingobjectposition.entityHit.setFire(5); } if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) { if (movingobjectposition.entityHit instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; if (!this.worldObj.isRemote) { entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); } if (this.knockbackStrength > 0) { f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f4 > 0.0F) { movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); } } if (this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); } if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); } } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); if (!(movingobjectposition.entityHit instanceof EntityEnderman)) { 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 { BlockPos blockpos1 = movingobjectposition.getBlockPos(); this.xTile = blockpos1.getX(); this.yTile = blockpos1.getY(); this.zTile = blockpos1.getZ(); iblockstate = this.worldObj.getBlockState(blockpos1); this.inTile = iblockstate.getBlock(); this.inData = this.inTile.getMetaFromState(iblockstate); this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double)f3 * 0.05000000074505806D; this.posY -= this.motionY / (double)f3 * 0.05000000074505806D; this.posZ -= this.motionZ / (double)f3 * 0.05000000074505806D; this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.arrowShake = 7; this.setIsCritical(false); if (this.inTile.getMaterial() != Material.air) { this.inTile.onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate, this); } } } if (this.getIsCritical()) { for (i = 0; i < 4; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.CRIT, this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ, new int[0]); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; f2 = 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)f2) * 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; f3 = 0.99F; f1 = 0.05F; if (this.isInWater()) { for (int l = 0; l < 4; ++l) { f4 = 0.25F; this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]); } f3 = 0.6F; } if (this.isWet()) { this.extinguish(); } this.motionX *= (double)f3; this.motionY *= (double)f3; this.motionZ *= (double)f3; this.motionY -= (double)f1; 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 tagCompound) { tagCompound.setShort("xTile", (short)this.xTile); tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); tagCompound.setShort("life", (short)this.ticksInGround); ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile); tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); tagCompound.setByte("inData", (byte)this.inData); tagCompound.setByte("shake", (byte)this.arrowShake); tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); tagCompound.setByte("pickup", (byte)this.canBePickedUp); tagCompound.setDouble("damage", this.damage); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { this.xTile = tagCompund.getShort("xTile"); this.yTile = tagCompund.getShort("yTile"); this.zTile = tagCompund.getShort("zTile"); this.ticksInGround = tagCompund.getShort("life"); if (tagCompund.hasKey("inTile", ) { this.inTile = Block.getBlockFromName(tagCompund.getString("inTile")); } else { this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255); } this.inData = tagCompund.getByte("inData") & 255; this.arrowShake = tagCompund.getByte("shake") & 255; this.inGround = tagCompund.getByte("inGround") == 1; if (tagCompund.hasKey("damage", 99)) { this.damage = tagCompund.getDouble("damage"); } if (tagCompund.hasKey("pickup", 99)) { this.canBePickedUp = tagCompund.getByte("pickup"); } else if (tagCompund.hasKey("player", 99)) { this.canBePickedUp = tagCompund.getBoolean("player") ? 1 : 0; } } /** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer entityIn) { if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityIn.capabilities.isCreativeMode; if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { flag = false; } if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityIn.onItemPickup(this, 1); this.setDead(); } } } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } public void setDamage(double p_70239_1_) { this.damage = p_70239_1_; } public double getDamage() { return this.damage; } /** * Sets the amount of knockback the arrow applies when it hits a mob. */ public void setKnockbackStrength(int p_70240_1_) { this.knockbackStrength = p_70240_1_; } /** * If returns false, the item will not inflict any damage against entities. */ public boolean canAttackWithItem() { return false; } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public void setIsCritical(boolean p_70243_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70243_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); } } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public boolean getIsCritical() { byte b0 = this.dataWatcher.getWatchableObjectByte(16); return (b0 & 1) != 0; } }
-
ñaaa the flechaMercenaria_entity class alredy has that only i ust paste the code i think relevant so i dont post that part package mercenarymod.items.arcos; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class flechaMercenaria_entity extends Entity implements IProjectile //EntityThrowable { //extend EntityThrowable/RenderThrowable private int xTile = -1; private int yTile = -1; private int zTile = -1; private Block inTile; private int inData; private boolean inGround; /** 1 if the player can pick up the arrow */ public int canBePickedUp; /** Seems to be some sort of timer for animating an arrow. */ public int arrowShake; /** The owner of this arrow. */ public Entity shootingEntity; private int ticksInGround; private int ticksInAir; private double damage = 2.0D; /** The amount of knockback an arrow applies when it hits a mob. */ private int knockbackStrength; private static final String __OBFID = "CL_00001715"; public flechaMercenaria_entity(World worldIn) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); } public flechaMercenaria_entity(World worldIn, double x, double y, double z) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); this.setPosition(x, y, z); } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D; double d0 = p_i1755_3_.posX - shooter.posX; double d1 = p_i1755_3_.getEntityBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY; double d2 = p_i1755_3_.posZ - shooter.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); double d4 = d0 / d3; double d5 = d2 / d3; this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3); float f4 = (float)(d3 * 0.20000000298023224D); this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_); } } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, float p_i1756_3_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.setSize(0.5F, 0.5F); this.setLocationAndAngles(shooter.posX , shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ , shooter.rotationYaw, shooter.rotationPitch); System.out.println( "##Nu se que es =>"+this.rotationYaw / 180.0F ); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * ((float)Math.PI) ) * 0.16F);//((float)Math.PI * 2 )m 0.16 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.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.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); } protected void entityInit() { this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. * * @param inaccuracy Higher means more error. */ public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { float f2 = MathHelper.sqrt_double(x * x + y * y + z * z); x /= (double)f2; y /= (double)f2; z /= (double)f2; x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; x *= (double)velocity; y *= (double)velocity; z *= (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f3 = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); this.ticksInGround = 0; } @SideOnly(Side.CLIENT) public void func_180426_a(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_, int p_180426_9_, boolean p_180426_10_) { this.setPosition(p_180426_1_, p_180426_3_, p_180426_5_); this.setRotation(p_180426_7_, p_180426_8_); } /** * Sets the velocity to the args. Args: x, y, z */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 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 f = 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)f) * 180.0D / Math.PI); } BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); Block block = iblockstate.getBlock(); System.out.println("world="+this.worldObj.isRemote+" "+" X="+this.posX+" Y="+this.posY+" Z="+this.posZ ); if (block.getMaterial() != Material.air) { block.setBlockBoundsBasedOnState(this.worldObj, blockpos); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, blockpos, iblockstate); if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.arrowShake > 0) { --this.arrowShake; } if (this.inGround) { int j = block.getMetaFromState(iblockstate); if (block == this.inTile && j == 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 vec31 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false); vec31 = new Vec3(this.posX, this.posY, this.posZ); vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int i; float f1; for (i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, (double)f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d1 = vec31.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) { movingobjectposition = null; } } float f2; float f3; float f4; if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int k = MathHelper.ceiling_double_int((double)f2 * this.damage); if (this.getIsCritical()) { k += this.rand.nextInt(k / 2 + 2); } DamageSource damagesource; if (this.shootingEntity == null) { damagesource = DamageSource.causeThrownDamage(this, this); } else { damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity); } if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { movingobjectposition.entityHit.setFire(5); } if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) { if (movingobjectposition.entityHit instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; if (!this.worldObj.isRemote) { entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); } if (this.knockbackStrength > 0) { f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f4 > 0.0F) { movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); } } if (this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); } if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); } } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); if (!(movingobjectposition.entityHit instanceof EntityEnderman)) { 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 { BlockPos blockpos1 = movingobjectposition.getBlockPos(); this.xTile = blockpos1.getX(); this.yTile = blockpos1.getY(); this.zTile = blockpos1.getZ(); iblockstate = this.worldObj.getBlockState(blockpos1); this.inTile = iblockstate.getBlock(); this.inData = this.inTile.getMetaFromState(iblockstate); this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double)f3 * 0.05000000074505806D; this.posY -= this.motionY / (double)f3 * 0.05000000074505806D; this.posZ -= this.motionZ / (double)f3 * 0.05000000074505806D; this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.arrowShake = 7; this.setIsCritical(false); if (this.inTile.getMaterial() != Material.air) { this.inTile.onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate, this); } } } if (this.getIsCritical()) { for (i = 0; i < 4; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.CRIT, this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ, new int[0]); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; f2 = 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)f2) * 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; f3 = 0.99F; f1 = 0.05F; if (this.isInWater()) { for (int l = 0; l < 4; ++l) { f4 = 0.25F; this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]); } f3 = 0.6F; } if (this.isWet()) { this.extinguish(); } this.motionX *= (double)f3; this.motionY *= (double)f3; this.motionZ *= (double)f3; this.motionY -= (double)f1; 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 tagCompound) { tagCompound.setShort("xTile", (short)this.xTile); tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); tagCompound.setShort("life", (short)this.ticksInGround); ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile); tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); tagCompound.setByte("inData", (byte)this.inData); tagCompound.setByte("shake", (byte)this.arrowShake); tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); tagCompound.setByte("pickup", (byte)this.canBePickedUp); tagCompound.setDouble("damage", this.damage); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { this.xTile = tagCompund.getShort("xTile"); this.yTile = tagCompund.getShort("yTile"); this.zTile = tagCompund.getShort("zTile"); this.ticksInGround = tagCompund.getShort("life"); if (tagCompund.hasKey("inTile", ) { this.inTile = Block.getBlockFromName(tagCompund.getString("inTile")); } else { this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255); } this.inData = tagCompund.getByte("inData") & 255; this.arrowShake = tagCompund.getByte("shake") & 255; this.inGround = tagCompund.getByte("inGround") == 1; if (tagCompund.hasKey("damage", 99)) { this.damage = tagCompund.getDouble("damage"); } if (tagCompund.hasKey("pickup", 99)) { this.canBePickedUp = tagCompund.getByte("pickup"); } else if (tagCompund.hasKey("player", 99)) { this.canBePickedUp = tagCompund.getBoolean("player") ? 1 : 0; } } /** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer entityIn) { if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityIn.capabilities.isCreativeMode; if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { flag = false; } if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityIn.onItemPickup(this, 1); this.setDead(); } } } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } public void setDamage(double p_70239_1_) { this.damage = p_70239_1_; } public double getDamage() { return this.damage; } /** * Sets the amount of knockback the arrow applies when it hits a mob. */ public void setKnockbackStrength(int p_70240_1_) { this.knockbackStrength = p_70240_1_; } /** * If returns false, the item will not inflict any damage against entities. */ public boolean canAttackWithItem() { return false; } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public void setIsCritical(boolean p_70243_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70243_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); } } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public boolean getIsCritical() { byte b0 = this.dataWatcher.getWatchableObjectByte(16); return (b0 & 1) != 0; } } actualy i think this is a bug and wont gona be able to solveit, just workaround it someone has a fully working custom arrow in 1.8 ??
-
it stills weird but sigthly less weird, the rended arrow in the local world does not match the angle and position of the arrow on the server, but hits the wool five seconds after the arrow hots wool the arrow returns to the position from which he was fired, but 40 seconds later it appears where it should maching position and angle with the arrow on the server. i do anything to the code is just a copy paste form vanillaArrow so lets do a test i add an System.out at the beginning of OnUpdate () of the flechaMercenaria_entity.class /** * Called to update the entity's position/logic. */ public void onUpdate() { if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = 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)f) * 180.0D / Math.PI); } BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); Block block = iblockstate.getBlock(); //###### System.out.println("world="+this.worldObj.isRemote+" "+" X="+this.posX+" Y="+this.posY+" Z="+this.posZ ); and get this surprise world=false X=1109.049806003033 Y=66.74721587954507 Z=264.42494798963395 world=true X=1114.90625 Y=66.5 Z=264.90625 world=false X=1109.049806003033 Y=66.74721587954507 Z=264.42494798963395 world=true X=1114.90625 Y=66.5 Z=264.90625 the EntityTracker class is not syncing well the position oof the arrow. Is there some way to force this update, the EntityTracker cclass has a method public void updateTrackedEntities(){} but no idea how to use it . thanks
-
thanks for thi answer i set the values to 64, 20, true soo this values are trackingRange, updateFrequency, sendsVelocityUpdates i been playing whit this values from what I saw tutorials registry arrows do not speak much about of these , and even whith these values its still do funny thing, the position of the arrow is not updated correctly the arrow is in place in server, but the rendering of the arrow is in another it goes whith wrong angle most of the time, after a few seconds the rendering of the arrow returns to the place from which it was fired, if I go out and save and reenter then the position of the render get fixed the only problem seems to be the render position you know how to solve this another render trouble ??
-
[1.8] ask if gui is open (any gui) ?? <SOLVED>
perromercenary00 replied to perromercenary00's topic in Modder Support
humm how do you ask what proxy server is being used ?? -
well i think the same, just the last week i learn how to make entitys but when i try to register this entity whit thath code the arrow begin to do weirds things in the first part of the video i set the arrow to just shoot on server side and register the arrow using the code taken from entities the arrow rotates to the left and remain still in the air like 9feets far from the woool wall sometimes and aroow get stuck in another arrow and sometimes the arrow damage the player when shoot, and is rare coz is just a copy paste from the code of the vainilla arrow in the secon part i disable the register for the arrow // registerArrow( mercenarymod.items.arcos.flechaMercenaria_entity.class , "flechaMercenaria"); and set the arrrow to shoot only in the local world, if i left it in the server it would be invisible whi this two change the arrow just behave like it must but this arrow dont causes damages to the mobs so far mi posibilities are 1: the entity is wrong register, 2: there must be some trick im not aware of 3: is a bug on 1.8 this is from mi main class @EventHandler public void preInit(FMLPreInitializationEvent event) { //entities registrarEntidad( mercenarymod.entidades.mobMercenario.class , "mobmercenario"); registrarEntidad( mercenarymod.entidades.yunoMercenaria.class , "yunoMercenaria"); registerArrow( mercenarymod.items.arcos.flechaMercenaria_entity.class , "flechaMercenaria"); } //register entity Arrow public static void registerArrow(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); long seed = name.hashCode(); Random rand = new Random(seed); int primaryColor = rand.nextInt() * 16777215; int secondaryColor = rand.nextInt() * 16777215; // EntityRegistry.registerGlobalEntityID(entityClass, name, entityID); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true); //EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); } //registrar entidad public static void registrarEntidad(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); long seed = name.hashCode(); Random rand = new Random(seed); int primaryColor = rand.nextInt() * 16777215; int secondaryColor = rand.nextInt() * 16777215; EntityRegistry.registerGlobalEntityID(entityClass, name, entityID); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true); EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); } What you tink could be the trouble ??
-
well long to explain, but i been waching various post whith same trouble i make a custom arrow flechaMercenaria_entity and has a custom render class flechaMercenaria_render and they are declared in the client proxi RenderingRegistry.registerEntityRenderingHandler( mercenarymod.items.arcos.flechaMercenaria_entity.class , new mercenarymod.items.arcos.flechaMercenaria_render( Minecraft.getMinecraft().getRenderManager() ) ); if i shoot this arrow only in the server side of an item class method // ####################################################################################3 @Override public ItemStack onItemRightClick(ItemStack prueba, World worldIn, EntityPlayer playerIn) { if (!worldIn.isRemote) { //net.minecraft.entity.projectile.EntityArrow arrow = new net.minecraft.entity.projectile.EntityArrow(worldIn, playerIn, 2F ); mercenarymod.items.arcos.flechaMercenaria_entity arrow = new mercenarymod.items.arcos.flechaMercenaria_entity(worldIn, playerIn, 2F ); worldIn.spawnEntityInWorld(arrow); playerIn.playSound("random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F); } } // ####################################################################################3 the arrow only exist in the server side does damage if hits creatures but is not spawning in local world and local wolrd is the one who draw the textures then the arrow is invisible if i change the (!worldIn.isRemote) for (worldIn.isRemote) the arrow only spawn in the local world the arrow render works perfect, this is a black arrow whith steel tip, but when hit some mob it dont make any damage and the arrow just bounce back an get stuck in the floor, this is coz the arrow not exist in server side and it must exist in server side to make damage but vainilla arrows has not this trouble if i only shoot vainilla arrow in server side it spawn as well in local world textures damage all works well soo i wass tinking arrow entityes must be declared the same way as normal entitys ?? none of the guides i read say something about, but all these guides are for 1,6 and 1.7. this is 1.8 cuold be diferent or just a bug thanks for thi answers
-
[1.8] ask if gui is open (any gui) ?? <SOLVED>
perromercenary00 replied to perromercenary00's topic in Modder Support
i make the trick whit (Minecraft.getMinecraft().currentScreen == null) // ######################################################################################3 public void onUpdate(ItemStack pistola, World worldIn, Entity playerIn, int itemSlot, boolean isSelected) { if (isSelected) { //only ask if in local world if (Mouse.isButtonDown(0) & !habilitado & hacerAlgo & worldIn.isRemote) { if (Minecraft.getMinecraft().currentScreen == null) { //send package to server informing of the leftclick action Mercenary.network.sendToServer(new mensajeMercenarioalServidor("leftclick")); } } } } -
[1.8] ask if gui is open (any gui) ?? <SOLVED>
perromercenary00 replied to perromercenary00's topic in Modder Support
is an turn around from a turn around i been doing // ######################################################################################3 public void onUpdate(ItemStack pistola, World worldIn, Entity playerIn, int itemSlot, boolean isSelected) { if (isSelected) { //only ask if in local world if (Mouse.isButtonDown(0) & !habilitado & hacerAlgo & worldIn.isRemote) { //send package to server informing of the leftclick action Mercenary.network.sendToServer(new mensajeMercenarioalServidor("leftclick")); } } } i set the gun way it shoots the normal 5.56munition on rigth click, but shoot the grenade launcher on left click, if you enter the inventory whith this gun in hand and accidentally press left click the grenade launcher shoots and bam you are death. in this other gun is not so bad coz leftClick is the chainsaw it will only kill whaever you have in front when wnter in the inventory and accidentally press leftClick -
goo days i been working in mi gun mods and have done something like an OnentityLeftClick method to use left click as if was a rigth click but left side i make an ak200 fusil whith grenade launcher and set the grenadelauncher part to shoot or reload on entity left click, this causes, if i pause the game and enter to inventory whith the gun selected and leftclick any slot or other item the gun shoots ad thas not good, is there some where something like if(gui.isopen) or if(playerIn.hasGuiOpen)
-
this is whath i been working on I managed to make some kind of OnItemLeftClick and whiit i been able to separate the two functions of the mark2 gun, chainsaw weapon works only when leftclick is held for more than 10 ticks, and the shooting only when right-clicking is pressed, in this case only full automode, I have the animations to load suspension Redstone activated and the animations to insert and remove the bullet magazine, just missing the paint job on the gun. no what i left what i want to do is * make that when the chainsaw catch some mob the screen fades to black and white as happen in the original gears of war, but I have no idea how this is done in minecraft *The other thing I want to do is to disable completely the ability to break blocks, at the end of the video I stay still holding left click in front of a block and it breaks but i dont want this to happen i want to disable thath thanks for the ideas
-
hellow i found something in the Mouse class and do /** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (isSelected) { if (Mouse.isButtonDown(0)) { System.out.println("Boton Zero"); } if (Mouse.isButtonDown(1)) { System.out.println("Boton uno"); } if (Mouse.isButtonDown(2)) { System.out.println("Boton dos"); } } }
-
good days i wanna do some tricki code but get stuck in the mere begining, well there is the method onItemRitgthClick but there is not an onItemLeftClick, only an entitySwing() i wanna do some code to make it to perform an action only when you hold left click for at least 8 Ticks but do nothing if yoy just press for less than 8 ticks and release leftclick but entitySwing just execute one time and nevermore until you release leftClick and press again soo i wass tincking, if i do some nbttag boolean leftclicked = true; inside the entitySwing method then make a loop inside onUpdate() to check if (leftclicked = true) {count 8 ticks} then ask if mouse leftclick is pressed in local world, then send message to server to execute the pieze of code in the item i want when hold leftclick for more than 8 ticks well thats the idea, the part whith i get stuck is how you make a keybind to check for mouse clicks, well i alredy have one working keybind class that check for keyboard's key_Minus key_asterisk and key_division and send messages to server, but i could realize howto to check for mouse events thats the ting i need help whith
-
good days this morning i learn how to make a custom entity and i have some question about what i can do and whath not this is what i have until now ambisious i wanna make something like a little maid mod but more bitch and a little yandere, and alredy realize how to make she use the guns of mi mod in the video she spawn whit an mp5t5 and shooot it but there is some troubles i want this to follow me around but the AI method this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); is only in the tameable class i declare the class of this mob whith public class yunoMercenaria extends EntityMob implements IRangedAttackMob { i need the IRangedAttackMob to make work the fireguns so icould' not get ride of it but if i declare it like tameable public class yunoMercenaria extends EntityTameable implements IRangedAttackMob { it dont crash it dont show any error but the mob dont spawn in the world the same happend if i try to make it EntityVillager it just work if i declare it like EntityMob so in this case is some hidden trick need to make an entityTameable ?? or i have to make workaround and do some custom new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); method compatible whith EntityMob class the other ting is that yuno hate itself soo if there is more than one they kill each other, is some way to set some target entitys exception ore something like ? yuno code this code is just a bunch of copypaste from vainilla entityes and the tutorial from http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571558-1-7-2-forge-add-new-block-item-entity-ai-creative package mercenarymod.entidades; import com.google.common.base.Predicate; import mercenarymod.items.MercenaryModItems; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIAvoidEntity; import net.minecraft.entity.ai.EntityAIFleeSun; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIRestrictSun; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; public class yunoMercenaria extends EntityMob implements IRangedAttackMob { //EntityMob private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F); private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false); private boolean canPickUpLoot=false; public yunoMercenaria(World worldIn) { super(worldIn); this.tasks.addTask(1, new EntityAISwimming(this)); //this.tasks.addTask(2, new EntityAIRestrictSun(this)); //this.tasks.addTask(2, this.field_175455_a); this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D)); this.tasks.addTask(3, new EntityAIAvoidEntity(this, new Predicate() { private static final String __OBFID = "CL_00002203"; public boolean func_179945_a(Entity p_179945_1_) { return p_179945_1_ instanceof EntityWolf; } public boolean apply(Object p_apply_1_) { return this.func_179945_a((Entity)p_apply_1_); } }, 6.0F, 1.0D, 1.2D)); //this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0])); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, true)); //this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true)); if (worldIn != null && !worldIn.isRemote) { this.setCombatTask(); } //this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.cuchillomercenario,1,0)); this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.subfusilMP5T5,1,1)); //this.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.50D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D); } public boolean isAIEnabled() { return true; } @Override public float getRenderSizeModifier() { return 0.5F; } @Override public boolean canPickUpLoot() { return this.canPickUpLoot; } /** * Attack the specified entity using a ranged attack. */ @Override public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { for (int i = 0; i < 3 ; i++ ){ //shoot four times System.out.println("Atacando a "+p_82196_1_.getName()); mercenarymod.items.armasdefuego.balas.bala9mm_entity bala9mm = new mercenarymod.items.armasdefuego.balas.bala9mm_entity(this.worldObj, this, p_82196_1_, 10F, 1.0F); int spell0 = 0;//EnchantmentHelper.getEfficiencyModifier(playerIn); int spell1 = 0;// EnchantmentHelper.getFortuneModifier(playerIn); int R = ((int) (Math.random() * 20)) + spell1; int tipomunicion = 3;//getInttag(pistola, "tipomunicion"); int cantDeEntidadesAfectadas=1; float damageM = 0.0F; float damageI = 0.0F; float precision = 0.0F; switch (tipomunicion) { default: damageM = 0.0F ; damageI = 0.0F ; cantDeEntidadesAfectadas=0; break; //Empty bullet case 1: damageM = 2.5F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_Hierro case 2: damageM = 3.0F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_redstone case 3: damageM = 3.5F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_obisidana } bala9mm.setPrecision(precision); bala9mm.setDamage(damageM); bala9mm.setDamageI(damageI); bala9mm.setCantDamage(cantDeEntidadesAfectadas); // critico if (R > 18) { bala9mm.setIsCritical(true); bala9mm.setDamage(bala9mm.getDamage() * 2); bala9mm.setCantDamage(cantDeEntidadesAfectadas + 1); // chat.chatr(playerIn, "critico"); } /* int spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, pistola); if (spell > 0) { bala9mm.setDamage(bala9mm.getDamage() + (float) spell * 0.5F + 0.5F); } spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, pistola); if (spell > 0) { bala9mm.setKnockbackStrength(spell); } spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, pistola); if (spell > 0) { bala9mm.setKnockbackStrength(spell); } if ( tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId , pistola) > 0) { bala9mm.setIsOnFire(true); } if ( tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId , pistola) > 0) { bala9mm.setIsOnFire(true); } */ this.playSound( "modmercenario:subfusilMP5T5_disparo", 0.4F, 0.4F); this.worldObj.spawnEntityInWorld(bala9mm); }//fin del for } public void setCombatTask() { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItem(); if (itemstack != null && itemstack.getItem() == MercenaryModItems.subfusilMP5T5) //Items.bow { this.tasks.addTask(4, this.aiArrowAttack); } else { this.tasks.addTask(4, this.aiAttackOnCollide); } } protected void func_180481_a(DifficultyInstance p_180481_1_) { super.func_180481_a(p_180481_1_); this.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); } /** * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot */ public void setCurrentItemOrArmor(int slotIn, ItemStack stack) { super.setCurrentItemOrArmor(slotIn, stack); if (!this.worldObj.isRemote && slotIn == 0) { this.setCombatTask(); } } public float getEyeHeight() { return 1.74F; } /** * Returns the Y Offset of this entity. */ public double getYOffset() { return super.getYOffset() - 0.5D; } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); /* if (tagCompund.hasKey("SkeletonType", 99)) { byte b0 = tagCompund.getByte("SkeletonType"); this.setSkeletonType(b0); } */ this.setCombatTask(); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); // tagCompound.setByte("SkeletonType", (byte)this.getSkeletonType()); } /* @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } */ }
-
[1.8] Can't figure out how to change bow pullback time.
perromercenary00 replied to Hardc0r3Br0n3's topic in Modder Support
yesterday i wass looking in the bow code searching for an answer to another trouble and i realy dont have idea how is dealing whith textures in 1.8 but you could still make it the same way than in 1.7 for the timing its just easy as play whith the methods and the values of useRemaining,count, and timeLeft //####################################################################################3 @Override public ModelResourceLocation getModel(ItemStack arco, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcoMercenarioDeCarbono", "inventory") ; int tick; tick=(1000-useRemaining); if (tick>999){tick=0;} int tipomunicion = getInttag(arco, "tipomunicion"); switch(tipomunicion){ default:{ if (tick > 0 & tick < 8 ){modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcoMercenarioDeCarbono_A00", "inventory");} if (tick > 7 & tick < 16 ){modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcoMercenarioDeCarbono_A01", "inventory") ;} if (tick > 15 & tick < 20 ){modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcoMercenarioDeCarbono_A02", "inventory") ;} if (tick > 19 ){modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcoMercenarioDeCarbono_A03", "inventory") ;} }break; } //####################################################################################3 @Override public void onUsingTick(ItemStack arco, EntityPlayer playerIn, int count) { int tick; tick=1000-count; int ciclo=8; if (tick == 1) { boolean shoot = getBooleantag(arco, "shoot"); if (!shoot) { playerIn.stopUsingItem(); } } } //#################################################################################################3 @Override public void onPlayerStoppedUsing(ItemStack arco, World worldIn, EntityPlayer playerIn, int timeLeft) { int tick; if (timeLeft>980){tick=20-(timeLeft-980);} else {tick=20;} float f=((tick/20F)*3.0F); /*code to shoot the arrow*/ } //#################################################################################################3 im not giving you all the code anyway i do some complex tings whit this one and it become long to explain but the 75000 is the maximun time you could keep the bow thigthn the arrow, i set thath value to only 1000 int tick; if (timeLeft>980){tick=20-(timeLeft-980);} else {tick=20;} float f=((tick/20F)*3.0F); float f is the strength whith which the arrow is shoot whith this code the bow needs only 20 ticks to reach their maximun strengh 3.0F vainilla needs 30 ticks to reach their maximun and is 2.0F -
sip thats one of the troubles done some changes , mi gui class is now a ticking class that only exist in local and send messages to server when finish all the ticks for animations come now from there. soo i have not to fear troubles in multiplayer anymore , but its still glichi some times its looks great other it just skip parts or all the animation the curious part is the ticks happen in mi gui/ticking class are taken from onRender(RenderGameOverlayEvent event) so it must be synced whith the method public ModelResourceLocation getModel(ItemStack pistola, EntityPlayer playerIn, int useRemaining) { } but its'n it
-
yap that s a trouble it will make the second item enter in onUse state actualy i been using an onupdate() to keep the animation going using an private int tick100; variable and like six nbttags to only afect the current gun/itme/magazine but has its troubles on update<tick> its not synced whith onreder<tick> causing the item to skip parts of the animation most of the time the whole animation and i fear if there is two player or more it will make the variable tick100 to count two or more times per onupdate<tick> setItemOnUse has not this troubles. but the other what else i could use to keep an animation goin ??
-
hello tis is little odd i been working in a fireguns mod and now im trying to improve the animations of mi guns when i take out the magazine or when put it in to, trying to reduce some graphical gliches i came whith this idea, if i could force the item to remain in use for at leats 20 tics(1sec) after i release rigth click i could improve the animation, but get stuck, i dont really know how to achive this this is the standar method in forge, you hold rigth click an this piece of code make the item enter to setItemInUse state and it remains that way until you release rigth click or something in the code execute playerIn.stopUsingItem(); // #########################################################################3 @Override public ItemStack onItemRightClick(ItemStack cargador, World worldIn, EntityPlayer playerIn) { playerIn.setItemInUse(cargador,this.getMaxItemUseDuration(cargador)); return cargador; } // #########################################################################3 i need the setItemInUse to keep working this other method for at least a second afther release the rigth click button // ####################################################################################3 @Override public ModelResourceLocation getModel(ItemStack gun, EntityPlayer playerIn, int useRemaining) { ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:cargador55645/cargador55645_CCe", "inventory"); } // ####################################################################################3 any idea ?? mod = http://www.curse.com/mc-mods/minecraft/228033-mercenarymod
-
[SOLVED] Preventing 1st-person item change animation?
perromercenary00 replied to coolAlias's topic in Modder Support
long ago i try something like but not soo deep like the yours http://www.minecraftforge.net/forum/index.php/topic,27461.msg140547.html#msg140547 an i have ideas but i could not disable the thing i call "switchAnimation" then i think the trouble is the nbttag system trigering it so if i dont use it it would'n be trouble then research and learn how to to write data to a json file creating a custom storing class whith the variables i need to use in this storing class i asign a serial number for every gun create whith mi mod to keep values from mixing betwin each other every five minutes a server ticks class check if the vaules in the storing class has change if its so it writes the values to the json file it is not then it leave it alono for another five minutes in teory works but then i realize the tragedy. when you set an item in use it triggers again the swtching animation so you could not avoid the animation what i do, just learn to live whith it making the code store al the nbttags from the shooting at same time to reduce the times the items switchs to only two per shoot http://www.curse.com/mc-mods/minecraft/228033-mercenarymod i not in your level whith the minecraft code this equippedProgress thing is an event caugth or where are you doing this