Advertisement
Corosus

Miner Zombie dig code

Aug 12th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.09 KB | None | 0 0
  1. public static void tryDig(EntityCreature entityliving, EntityLiving entityliving1) {
  2.        if(entityliving1 == null) {
  3.            return;
  4.        }
  5.  
  6.        float f = 2.0F;
  7.        float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  8.        float f2 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  9.        f1 = 0.0F;
  10.        float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
  11.        int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
  12.        f3 = (float)i * 90F;
  13.        double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
  14.        double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset;
  15.        double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
  16.        Vec3D vec3d = Vec3D.createVector(d, d1, d2);
  17.        float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
  18.        float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
  19.        float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
  20.        float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
  21.        float f8 = f5 * f6;
  22.        float f9 = f7;
  23.        float f10 = f4 * f6;
  24.        entityliving.info = f3;
  25.        double d3 = 1.0D;
  26.        double d4 = 1.8D;
  27.        double d5 = 0.050000000000000003D;
  28.        Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
  29.        MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
  30.  
  31.        if(movingobjectposition == null) {
  32.            return;
  33.        }
  34.  
  35.        int j = MathHelper.floor_float((float)(entityliving.posX - entityliving1.posX));
  36.        int k = (int)(entityliving.posY - entityliving1.posY);
  37.        int l = MathHelper.floor_float((float)(entityliving.posZ - entityliving1.posZ));
  38.        boolean flag = false;
  39.  
  40.        if(j + l > 0) {
  41.            if((float)(k / (j + l)) > 1.0F) {
  42.                flag = true;
  43.            }
  44.        } else if(k > 2) {
  45.            flag = true;
  46.        }
  47.  
  48.        if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE || flag) {
  49.            int i2 = f2 >= -20F ? 0 : 1;
  50.            int i1;
  51.            int j1;
  52.            int k1;
  53.  
  54.            if(flag) {
  55.                i1 = (int)entityliving.posX;
  56.                j1 = (int)entityliving.posZ - 1;
  57.                k1 = (int)entityliving.posZ;
  58.            } else {
  59.                i1 = movingobjectposition.blockX;
  60.                j1 = movingobjectposition.blockY + i2;
  61.                k1 = movingobjectposition.blockZ;
  62.            }
  63.  
  64.            int l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  65.  
  66.            if(l1 == 0 && (i2 == 1 || flag)) {
  67.                j1--;
  68.                l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  69.  
  70.                if(l1 == 0 && i2 == 1) {
  71.                    j1--;
  72.                    l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  73.                }
  74.            }
  75.  
  76.            if(i1 != entityliving.curBlockX || j1 != entityliving.curBlockZ) {
  77.                entityliving.curBlockDmg = 0.0F;
  78.                entityliving.curBlockX = i1;
  79.                entityliving.curBlockZ = j1;
  80.            }
  81.  
  82.            Block block = Block.blocksList[l1];
  83.            float f11 = MiningZombieDigPower.get() * (float)(entityliving.nearbyMinerCount + 1);
  84.  
  85.            if(block != null) {
  86.                if(entityliving instanceof EntityZombieMiner) {
  87.                    ((EntityZombieMiner)entityliving).swingArm = true;
  88.                }
  89.  
  90.                double d6 = (double)f8 * d5;
  91.                double d7 = (double)f9 * d5;
  92.                double d8 = (double)f10 * d5;
  93.  
  94.                for(int j2 = 0; j2 <= (int)entityliving.curBlockDmg; j2++) {
  95.                    entityliving.worldObj.spawnParticle("explode", d + ((double)f8 * d4 + (double)(entityliving.worldObj.rand.nextFloat() * (entityliving.curBlockDmg / 10F))), d1 + (double)f9 * d4 + 0.0D + (double)((entityliving.worldObj.rand.nextFloat() * entityliving.curBlockDmg) / 10F), d2 + ((double)f10 * d4 + (double)((entityliving.worldObj.rand.nextFloat() * entityliving.curBlockDmg) / 10F)), 0.0D, 0.0D, 0.0D);
  96.                }
  97.  
  98.                mc.effectRenderer.addBlockHitEffects((int)i1, (int)j1, (int)k1, 0);
  99.                
  100.                entityliving.worldObj.playSoundAtEntity(entityliving, "step.stone", 1.0F, 1.0F / (entityliving.worldObj.rand.nextFloat() * 0.4F + 0.8F));
  101.                entityliving.curBlockDmg += f11 / (float)block.blockHardness;
  102.  
  103.                if(entityliving.getDistanceToEntity(theplayer) >= 17F);
  104.  
  105.                if(entityliving.curBlockDmg > 10F) {
  106.                    entityliving.curBlockDmg = 0.0F;
  107.                    mc.effectRenderer.addBlockDestroyEffects((int)i1, (int)j1, (int)k1, 1, 0);
  108.                    entityliving.worldObj.spawnParticle("flame", d + (double)f8 * d4, d1 + (double)f9 * d4, d2 + (double)f10 * d4, d6 / 2D, d7 / 2D, d8 / 2D);
  109.                    entityliving.worldObj.setBlockWithNotify(i1, j1, k1, 0);
  110.                    mineComplete(entityliving);
  111.                    entityliving.nearbyMinerCount = 0;
  112.                    Object obj = null;
  113.                    List list = entityliving.worldObj.getEntitiesWithinAABBExcludingEntity(entityliving, entityliving.boundingBox.expand(2D, 2D, 2D));
  114.  
  115.                    if(list != null) {
  116.                        for(int k2 = 0; k2 < list.size(); k2++) {
  117.                            Entity entity = (Entity)list.get(k2);
  118.  
  119.                            if(entity instanceof EntityCreature) {
  120.                                entityliving.nearbyMinerCount++;
  121.                                mineComplete((EntityCreature)entity);
  122.                            }
  123.                        }
  124.                    }
  125.                }
  126.  
  127.                if(entityliving.worldObj.getBlockMaterial(i1, j1, k1) != Material.ground) {
  128.                    if(entityliving.worldObj.getBlockMaterial(i1, j1, k1) != Material.rock);
  129.                }
  130.            }
  131.        }
  132.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement