예제 #1
1
  /** Adds an entity to the chunk. Args: entity */
  public void addEntity(Entity par1Entity) {
    this.hasEntities = true;
    int var2 = MathHelper.floor_double(par1Entity.posX / 16.0D);
    int var3 = MathHelper.floor_double(par1Entity.posZ / 16.0D);

    if (var2 != this.xPosition || var3 != this.zPosition) {
      this.worldObj.func_98180_V().func_98232_c("Wrong location! " + par1Entity);
      Thread.dumpStack();
    }

    int var4 = MathHelper.floor_double(par1Entity.posY / 16.0D);

    if (var4 < 0) {
      var4 = 0;
    }

    if (var4 >= this.entityLists.length) {
      var4 = this.entityLists.length - 1;
    }

    par1Entity.addedToChunk = true;
    par1Entity.chunkCoordX = this.xPosition;
    par1Entity.chunkCoordY = var4;
    par1Entity.chunkCoordZ = this.zPosition;
    this.entityLists[var4].add(par1Entity);
  }
예제 #2
0
  /**
   * Takes in the distance the entity has fallen this tick and whether its on the ground to update
   * the fall distance and deal fall damage if landing on the ground. Args: distanceFallenThisTick,
   * onGround
   */
  protected void updateFallState(double par1, boolean par3) {
    if (par3) {
      if (fallDistance > 0.0F) {
        if (this instanceof EntityLiving) {
          int i = MathHelper.floor_double(posX);
          int j = MathHelper.floor_double(posY - 0.2D - (double) yOffset);
          int k = MathHelper.floor_double(posZ);
          int l = worldObj.getBlockId(i, j, k);

          if (l == 0 && worldObj.getBlockId(i, j - 1, k) == Block.fence.blockID) {
            l = worldObj.getBlockId(i, j - 1, k);
          }

          if (l > 0) {
            Block.blocksList[l].onFallenUpon(worldObj, i, j, k, this, fallDistance);
          }
        }

        fall(fallDistance);
        fallDistance = 0.0F;
      }
    } else if (par1 < 0.0D) {
      fallDistance -= par1;
    }
  }
예제 #3
0
 /** Checks if this entity is either in water or on an open air block in rain (used in wolves). */
 public boolean isWet() {
   return inWater
       || worldObj.canLightningStrikeAt(
           MathHelper.floor_double(posX),
           MathHelper.floor_double(posY),
           MathHelper.floor_double(posZ));
 }
예제 #4
0
  /** Checks if the entity's current position is a valid location to spawn this entity. */
  public boolean getCanSpawnHere() {
    if (worldObj.rand.nextInt(3) == 0) {
      return false;
    }

    if (worldObj.checkIfAABBIsClear(boundingBox)
        && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0
        && !worldObj.isAnyLiquid(boundingBox)) {
      int i = MathHelper.floor_double(posX);
      int j = MathHelper.floor_double(boundingBox.minY);
      int k = MathHelper.floor_double(posZ);

      if (j < 63) {
        return false;
      }

      int l = worldObj.getBlockId(i, j - 1, k);

      if (l == Block.grass.blockID || l == Block.leaves.blockID) {
        return true;
      }
    }

    return false;
  }
 public boolean isOnLadder() {
   int i = MathHelper.floor_double(posX);
   int j = MathHelper.floor_double(boundingBox.minY);
   int k = MathHelper.floor_double(posZ);
   return worldObj.getBlockId(i, j, k) == Block.ladder.blockID
       || worldObj.getBlockId(i, j + 1, k) == Block.ladder.blockID;
 }
예제 #6
0
 public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
   super.readEntityFromNBT(nbttagcompound);
   NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory");
   inventory.readFromNBT(nbttaglist);
   dimension = nbttagcompound.getInteger("Dimension");
   sleeping = nbttagcompound.getBoolean("Sleeping");
   sleepTimer = nbttagcompound.getShort("SleepTimer");
   currentXP = nbttagcompound.getFloat("XpP");
   playerLevel = nbttagcompound.getInteger("XpLevel");
   totalXP = nbttagcompound.getInteger("XpTotal");
   if (sleeping) {
     bedChunkCoordinates =
         new ChunkCoordinates(
             MathHelper.floor_double(posX),
             MathHelper.floor_double(posY),
             MathHelper.floor_double(posZ));
     wakeUpPlayer(true, true, false);
   }
   if (nbttagcompound.hasKey("SpawnX")
       && nbttagcompound.hasKey("SpawnY")
       && nbttagcompound.hasKey("SpawnZ")) {
     playerSpawnCoordinate =
         new ChunkCoordinates(
             nbttagcompound.getInteger("SpawnX"),
             nbttagcompound.getInteger("SpawnY"),
             nbttagcompound.getInteger("SpawnZ"));
   }
   foodStats.readStatsFromNBT(nbttagcompound);
   capabilities.readCapabilitiesFromNBT(nbttagcompound);
 }
예제 #7
0
 public void onUpdate() {
   super.onUpdate();
   if (getPuffed()) {
     fallDistance = 0.0F;
     if (motionY < -0.050000000000000003D) {
       motionY = -0.050000000000000003D;
     }
   }
   if (rand.nextInt(100) == 0) {
     int i = MathHelper.floor_double(posX);
     int j = MathHelper.floor_double(posY);
     int k = MathHelper.floor_double(posZ);
     if (worldObj.getBlockId(i, j - 1, k) == AetherBlocks.Grass.blockID) {
       worldObj.setBlockWithNotify(i, j - 1, k, AetherBlocks.Dirt.blockID);
       amountEaten++;
     }
   }
   if (amountEaten == 5 && !getSheared() && !getPuffed()) {
     setPuffed(true);
     amountEaten = 0;
   }
   if (amountEaten == 10 && getSheared() && !getPuffed()) {
     setSheared(false);
     setFleeceColor(0);
     amountEaten = 0;
   }
 }
예제 #8
0
  /**
   * Gets all entities that can be assigned to the specified class. Args: entityClass, aabb,
   * listToFill
   */
  public void getEntitiesOfTypeWithinAAAB(
      Class par1Class,
      AxisAlignedBB par2AxisAlignedBB,
      List par3List,
      IEntitySelector par4IEntitySelector) {
    int var5 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
    int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);

    if (var5 < 0) {
      var5 = 0;
    } else if (var5 >= this.entityLists.length) {
      var5 = this.entityLists.length - 1;
    }

    if (var6 >= this.entityLists.length) {
      var6 = this.entityLists.length - 1;
    } else if (var6 < 0) {
      var6 = 0;
    }

    for (int var7 = var5; var7 <= var6; ++var7) {
      List var8 = this.entityLists[var7];

      for (int var9 = 0; var9 < var8.size(); ++var9) {
        Entity var10 = (Entity) var8.get(var9);

        if (par1Class.isAssignableFrom(var10.getClass())
            && var10.boundingBox.intersectsWith(par2AxisAlignedBB)
            && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(var10))) {
          par3List.add(var10);
        }
      }
    }
  }
예제 #9
0
 /** Called to update the entity's position/logic. */
 public void onUpdate() {
   if (this.worldObj.blockExists(
       MathHelper.floor_double(this.posX), 0, MathHelper.floor_double(this.posZ))) {
     super.onUpdate();
     this.sendMotionUpdates();
   }
 }
예제 #10
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readEntityFromNBT(par1NBTTagCompound);
    NBTTagList var2 = par1NBTTagCompound.getTagList("Inventory");
    this.inventory.readFromNBT(var2);
    this.dimension = par1NBTTagCompound.getInteger("Dimension");
    this.sleeping = par1NBTTagCompound.getBoolean("Sleeping");
    this.sleepTimer = par1NBTTagCompound.getShort("SleepTimer");
    this.experience = par1NBTTagCompound.getFloat("XpP");
    this.experienceLevel = par1NBTTagCompound.getInteger("XpLevel");
    this.experienceTotal = par1NBTTagCompound.getInteger("XpTotal");

    if (this.sleeping) {
      this.playerLocation =
          new ChunkCoordinates(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY),
              MathHelper.floor_double(this.posZ));
      this.wakeUpPlayer(true, true, false);
    }

    if (par1NBTTagCompound.hasKey("SpawnX")
        && par1NBTTagCompound.hasKey("SpawnY")
        && par1NBTTagCompound.hasKey("SpawnZ")) {
      this.spawnChunk =
          new ChunkCoordinates(
              par1NBTTagCompound.getInteger("SpawnX"),
              par1NBTTagCompound.getInteger("SpawnY"),
              par1NBTTagCompound.getInteger("SpawnZ"));
    }

    this.foodStats.readNBT(par1NBTTagCompound);
    this.capabilities.readCapabilitiesFromNBT(par1NBTTagCompound);
  }
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    if (this.worldObj.isDaytime() && !this.worldObj.isRemote) {
      float var1 = this.getBrightness(1.0F);

      if (var1 > 0.5F
          && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F
          && this.worldObj.canBlockSeeTheSky(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY),
              MathHelper.floor_double(this.posZ))) {
        boolean var2 = true;
        ItemStack var3 = this.getCurrentItemOrArmor(4);

        if (var3 != null) {
          if (var3.isItemStackDamageable()) {
            var3.setItemDamage(var3.getItemDamageForDisplay() + this.rand.nextInt(2));

            if (var3.getItemDamageForDisplay() >= var3.getMaxDamage()) {
              this.renderBrokenItemStack(var3);
              this.setCurrentItemOrArmor(4, (ItemStack) null);
            }
          }

          var2 = false;
        }

        if (var2) {
          this.setFire(8);
        }
      }
    }

    super.onLivingUpdate();
  }
예제 #12
0
  public void killElevator() {
    int var1 = MathHelper.floor_double(this.posX);
    int var2 = MathHelper.floor_double(this.posY);
    int var3 = MathHelper.floor_double(this.posZ);
    int var4 = MathHelper.floor_double(this.posY);

    if (!this.isCeiling() && this.namedFloors != null && this.properties != null) {
      ElevatorsCore.checkedFloorNames.put(new ChunkPosition(var1, var4, var3), this.namedFloors);
      ElevatorsCore.checkedProperties.put(new ChunkPosition(var1, var4, var3), this.properties);
    }

    if (!this.worldObj.isRemote
        && this.worldObj.getBlockId(var1, var4, var3) != blockID
        && (!this.worldObj.canBlockBePlacedAt(blockID, var1, var4, var3, true, 1)
            || !this.worldObj.setBlockWithNotify(var1, var4, var3, blockID))) {
      this.dropItem(blockID, 1);
      this.setDead();
      this.say("Entity Dead - Destination blocked!");
    } else if (!this.worldObj.isRemote) {
      this.setDead();
      this.say("Entity Dead");
    }

    this.ejectRiders();
  }
예제 #13
0
 public boolean getCanSpawnHere() {
   int i = MathHelper.floor_double(posX);
   int j = MathHelper.floor_double(boundingBox.minY);
   int k = MathHelper.floor_double(posZ);
   return worldObj.getBlockId(i, j - 1, k) == Block.grass.blockID
       && worldObj.getFullBlockLightValue(i, j, k) > 8
       && super.getCanSpawnHere();
 }
예제 #14
0
  protected boolean teleportTo(double par1, double par3, double par5) {
    double d = posX;
    double d1 = posY;
    double d2 = posZ;
    posX = par1;
    posY = par3;
    posZ = par5;
    boolean flag = false;
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_double(posY);
    int k = MathHelper.floor_double(posZ);

    if (worldObj.blockExists(i, j, k)) {
      boolean flag1;

      for (flag1 = false; !flag1 && j > 0; ) {
        int i1 = worldObj.getBlockId(i, j - 1, k);

        if (i1 == 0 || !Block.blocksList[i1].blockMaterial.blocksMovement()) {
          posY--;
          j--;
        } else {
          flag1 = true;
        }
      }

      if (flag1) {
        setPosition(posX, posY, posZ);

        if (worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0
            && !worldObj.isAnyLiquid(boundingBox)) {
          flag = true;
        }
      }
    }

    if (!flag) {
      setPosition(d, d1, d2);
      return false;
    }

    int l = 128;

    for (int j1 = 0; j1 < l; j1++) {
      double d3 = (double) j1 / ((double) l - 1.0D);
      float f = (rand.nextFloat() - 0.5F) * 0.2F;
      float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
      float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
      double d4 = d + (posX - d) * d3 + (rand.nextDouble() - 0.5D) * (double) width * 2D;
      double d5 = d1 + (posY - d1) * d3 + rand.nextDouble() * (double) height;
      double d6 = d2 + (posZ - d2) * d3 + (rand.nextDouble() - 0.5D) * (double) width * 2D;
      worldObj.spawnParticle("portal", d4, d5, d6, f, f1, f2);
    }

    worldObj.playSoundEffect(d, d1, d2, "mob.endermen.portal", 1.0F, 1.0F);
    worldObj.playSoundAtEntity(this, "mob.endermen.portal", 1.0F, 1.0F);
    return true;
  }
 public boolean getCanSpawnHere() {
   Chunk chunk =
       worldObj.getChunkFromBlockCoords(
           MathHelper.floor_double(posX), MathHelper.floor_double(posZ));
   return (getSlimeSize() == 1 || worldObj.difficultySetting > 0)
       && rand.nextInt(10) == 0
       && chunk.func_997_a(0x3ad8025fL).nextInt(10) == 0
       && posY < 16D;
 }
예제 #16
0
  public Packet71Weather(Entity par1Entity) {
    entityID = par1Entity.entityId;
    posX = MathHelper.floor_double(par1Entity.posX * 32D);
    posY = MathHelper.floor_double(par1Entity.posY * 32D);
    posZ = MathHelper.floor_double(par1Entity.posZ * 32D);

    if (par1Entity instanceof EntityLightningBolt) {
      isLightningBolt = 1;
    }
  }
예제 #17
0
 public Packet24MobSpawn(EntityLiving entityliving) {
   entityId = entityliving.entityId;
   type = (byte) EntityList.getEntityID(entityliving);
   xPosition = MathHelper.floor_double(entityliving.posX * 32D);
   yPosition = MathHelper.floor_double(entityliving.posY * 32D);
   zPosition = MathHelper.floor_double(entityliving.posZ * 32D);
   yaw = (byte) (int) ((entityliving.rotationYaw * 256F) / 360F);
   pitch = (byte) (int) ((entityliving.rotationPitch * 256F) / 360F);
   metaData = entityliving.getDataWatcher();
 }
예제 #18
0
  /** handles entity death timer, experience orb and particle creation */
  protected void onDeathUpdate() {
    ++this.deathTicks;

    if (this.deathTicks >= 180 && this.deathTicks <= 200) {
      float var1 = (this.rand.nextFloat() - 0.5F) * 8.0F;
      float var2 = (this.rand.nextFloat() - 0.5F) * 4.0F;
      float var3 = (this.rand.nextFloat() - 0.5F) * 8.0F;
      this.worldObj.spawnParticle(
          "hugeexplosion",
          this.posX + (double) var1,
          this.posY + 2.0D + (double) var2,
          this.posZ + (double) var3,
          0.0D,
          0.0D,
          0.0D);
    }

    int var4;
    int var5;

    if (!this.worldObj.isRemote) {
      if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
        var4 = 1000;

        while (var4 > 0) {
          var5 = EntityXPOrb.getXPSplit(var4);
          var4 -= var5;
          this.worldObj.spawnEntityInWorld(
              new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, var5));
        }
      }

      if (this.deathTicks == 1) {
        this.worldObj.func_82739_e(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
      }
    }

    this.moveEntity(0.0D, 0.10000000149011612D, 0.0D);
    this.renderYawOffset = this.rotationYaw += 20.0F;

    if (this.deathTicks == 200 && !this.worldObj.isRemote) {
      var4 = 2000;

      while (var4 > 0) {
        var5 = EntityXPOrb.getXPSplit(var4);
        var4 -= var5;
        this.worldObj.spawnEntityInWorld(
            new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, var5));
      }

      this.createEnderPortal(
          MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ));
      this.setDead();
    }
  }
예제 #19
0
  /** checks to make sure painting can be placed there */
  public boolean onValidSurface() {
    if (worldObj.getCollidingBoundingBoxes(this, boundingBox).size() > 0) {
      return false;
    }

    int i = art.sizeX / 16;
    int j = art.sizeY / 16;
    int k = xPosition;
    int l = yPosition;
    int i1 = zPosition;

    if (direction == 0) {
      k = MathHelper.floor_double(posX - (double) ((float) art.sizeX / 32F));
    }

    if (direction == 1) {
      i1 = MathHelper.floor_double(posZ - (double) ((float) art.sizeX / 32F));
    }

    if (direction == 2) {
      k = MathHelper.floor_double(posX - (double) ((float) art.sizeX / 32F));
    }

    if (direction == 3) {
      i1 = MathHelper.floor_double(posZ - (double) ((float) art.sizeX / 32F));
    }

    l = MathHelper.floor_double(posY - (double) ((float) art.sizeY / 32F));

    for (int j1 = 0; j1 < i; j1++) {
      for (int k1 = 0; k1 < j; k1++) {
        Material material;

        if (direction == 0 || direction == 2) {
          material = worldObj.getBlockMaterial(k + j1, l + k1, zPosition);
        } else {
          material = worldObj.getBlockMaterial(xPosition, l + k1, i1 + j1);
        }

        if (!material.isSolid()) {
          return false;
        }
      }
    }

    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox);

    for (int l1 = 0; l1 < list.size(); l1++) {
      if (list.get(l1) instanceof EntityPainting) {
        return false;
      }
    }

    return true;
  }
  protected boolean func_48376_a(EntityLiving par1EntityLiving, boolean par2) {
    if (par1EntityLiving == null) {
      return false;
    } else if (par1EntityLiving == this.taskOwner) {
      return false;
    } else if (!par1EntityLiving.isEntityAlive()) {
      return false;
    } else {
      if (!this.taskOwner.func_48100_a(par1EntityLiving.getClass())) {
        return false;
      } else {
        if (this.taskOwner instanceof EntityTameable
            && ((EntityTameable) this.taskOwner).isTamed()) {
          if (par1EntityLiving instanceof EntityTameable
              && ((EntityTameable) par1EntityLiving).isTamed()) {
            return false;
          }

          if (par1EntityLiving == ((EntityTameable) this.taskOwner).getOwner()) {
            return false;
          }
        } else if (par1EntityLiving instanceof EntityPlayer
            && !par2 /*&& ((EntityPlayer)par1EntityLiving).capabilities.disableDamage*/) {
          return false;
        }

        if (!this.taskOwner.isWithinHomeDistance(
            MathHelper.floor_double(par1EntityLiving.posX),
            MathHelper.floor_double(par1EntityLiving.posY),
            MathHelper.floor_double(par1EntityLiving.posZ))) {
          return false;
        } else if (this.field_48380_e
            && !this.taskOwner.getEntitySenses().canSee(par1EntityLiving)) {
          return false;
        } else {
          if (this.field_48383_a) {
            if (--this.field_48377_f <= 0) {
              this.field_48381_b = 0;
            }

            if (this.field_48381_b == 0) {
              this.field_48381_b = this.func_48375_a(par1EntityLiving) ? 1 : 2;
            }

            if (this.field_48381_b == 2) {
              return false;
            }
          }

          return true;
        }
      }
    }
  }
예제 #21
0
  public int getBrightnessForRender(float par1) {
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_double(posZ);

    if (worldObj.blockExists(i, 0, j)) {
      double d = (boundingBox.maxY - boundingBox.minY) * 0.66000000000000003D;
      int k = MathHelper.floor_double((posY - (double) yOffset) + d);
      return worldObj.getLightBrightnessForSkyBlocks(i, k, j, 0);
    } else {
      return 0;
    }
  }
예제 #22
0
  /** Gets how bright this entity is. */
  public float getEntityBrightness(float par1) {
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_double(posZ);

    if (worldObj.blockExists(i, 0, j)) {
      double d = (boundingBox.maxY - boundingBox.minY) * 0.66D;
      int k = MathHelper.floor_double((posY - (double) yOffset) + d);
      return worldObj.getLightBrightness(i, k, j);
    } else {
      return 0.0F;
    }
  }
예제 #23
0
 public EntityTrackerEntry(Entity par1Entity, int par2, int par3, boolean par4) {
   this.myEntity = par1Entity;
   this.blocksDistanceThreshold = par2;
   this.updateFrequency = par3;
   this.sendVelocityUpdates = par4;
   this.lastScaledXPosition = MathHelper.floor_double(par1Entity.posX * 32.0D);
   this.lastScaledYPosition = MathHelper.floor_double(par1Entity.posY * 32.0D);
   this.lastScaledZPosition = MathHelper.floor_double(par1Entity.posZ * 32.0D);
   this.lastYaw = MathHelper.floor_float(par1Entity.rotationYaw * 256.0F / 360.0F);
   this.lastPitch = MathHelper.floor_float(par1Entity.rotationPitch * 256.0F / 360.0F);
   this.lastHeadMotion = MathHelper.floor_float(par1Entity.setRotationYawHead() * 256.0F / 360.0F);
 }
 public static String func_85074_a(double par0, double par2, double par4) {
   return String.format(
       "%.2f,%.2f,%.2f - %s",
       new Object[] {
         Double.valueOf(par0),
         Double.valueOf(par2),
         Double.valueOf(par4),
         func_85071_a(
             MathHelper.floor_double(par0),
             MathHelper.floor_double(par2),
             MathHelper.floor_double(par4))
       });
 }
예제 #25
0
  public void onLivingUpdate() {
    if (this.worldObj.isDaytime() && !this.worldObj.multiplayerWorld) {
      float var1 = this.getEntityBrightness(1.0F);
      if (var1 > 0.5F
          && this.worldObj.canBlockSeeTheSky(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY),
              MathHelper.floor_double(this.posZ))
          && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F) {
        this.func_40046_d(8);
      }
    }

    super.onLivingUpdate();
  }
예제 #26
0
  /** Checks if the current block the entity is within of the specified material type */
  public boolean isInsideOfMaterial(Material par1Material) {
    double d = posY + (double) getEyeHeight();
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_float(MathHelper.floor_double(d));
    int k = MathHelper.floor_double(posZ);
    int l = worldObj.getBlockId(i, j, k);

    if (l != 0 && Block.blocksList[l].blockMaterial == par1Material) {
      float f = BlockFluid.getFluidHeightPercent(worldObj.getBlockMetadata(i, j, k)) - 0.1111111F;
      float f1 = (float) (j + 1) - f;
      return d < (double) f1;
    } else {
      return false;
    }
  }
예제 #27
0
  /** Renders all the overlays that are in first person mode. Args: partialTickTime */
  public void renderOverlays(float par1) {
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    int var2;

    if (this.mc.thePlayer.isBurning()) {
      var2 = this.mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
      this.renderFireInFirstPerson(par1);
    }

    if (this.mc.thePlayer.isEntityInsideOpaqueBlock()) {
      var2 = MathHelper.floor_double(this.mc.thePlayer.posX);
      int var3 = MathHelper.floor_double(this.mc.thePlayer.posY);
      int var4 = MathHelper.floor_double(this.mc.thePlayer.posZ);
      int var5 = this.mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5);
      int var6 = this.mc.theWorld.getBlockId(var2, var3, var4);

      if (this.mc.theWorld.isBlockNormalCube(var2, var3, var4)) {
        this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
      } else {
        for (int var7 = 0; var7 < 8; ++var7) {
          float var8 = ((float) ((var7 >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
          float var9 = ((float) ((var7 >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F;
          float var10 = ((float) ((var7 >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
          int var11 = MathHelper.floor_float((float) var2 + var8);
          int var12 = MathHelper.floor_float((float) var3 + var9);
          int var13 = MathHelper.floor_float((float) var4 + var10);

          if (this.mc.theWorld.isBlockNormalCube(var11, var12, var13)) {
            var6 = this.mc.theWorld.getBlockId(var11, var12, var13);
          }
        }
      }

      if (Block.blocksList[var6] != null) {
        this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
      }
    }

    if (this.mc.thePlayer.isInsideOfMaterial(Material.water)) {
      var2 = this.mc.renderEngine.getTexture("/misc/water.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
      this.renderWarpedTextureOverlay(par1);
    }

    GL11.glEnable(GL11.GL_ALPHA_TEST);
  }
예제 #28
0
  @Override
  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving) {
    if (!(world.getBlockMetadata(x, y, z) == 6)) {
      TileEntityBasicMachine tileEntity =
          (TileEntityBasicMachine) world.getBlockTileEntity(x, y, z);
      int side =
          MathHelper.floor_double((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
      int change = 3;

      switch (side) {
        case 0:
          change = 2;
          break;
        case 1:
          change = 5;
          break;
        case 2:
          change = 3;
          break;
        case 3:
          change = 4;
          break;
      }

      tileEntity.setFacing((short) change);
    }
  }
예제 #29
0
  /** Checks if this entity is inside of an opaque block */
  public boolean isEntityInsideOpaqueBlock() {
    for (int i = 0; i < 8; i++) {
      float f = ((float) ((i >> 0) % 2) - 0.5F) * width * 0.8F;
      float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F;
      float f2 = ((float) ((i >> 2) % 2) - 0.5F) * width * 0.8F;
      int j = MathHelper.floor_double(posX + (double) f);
      int k = MathHelper.floor_double(posY + (double) getEyeHeight() + (double) f1);
      int l = MathHelper.floor_double(posZ + (double) f2);

      if (worldObj.isBlockNormalCube(j, k, l)) {
        return true;
      }
    }

    return false;
  }
예제 #30
0
  /** gets the way this piston should face for that entity that placed it. */
  private static int determineOrientation(
      World par0World, int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
    if (MathHelper.abs((float) par4EntityPlayer.posX - (float) par1) < 2.0F
        && MathHelper.abs((float) par4EntityPlayer.posZ - (float) par3) < 2.0F) {
      double d = (par4EntityPlayer.posY + 1.8200000000000001D) - (double) par4EntityPlayer.yOffset;

      if (d - (double) par2 > 2D) {
        return 1;
      }

      if ((double) par2 - d > 0.0D) {
        return 0;
      }
    }

    int i =
        MathHelper.floor_double((double) ((par4EntityPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;

    if (i == 0) {
      return 2;
    }

    if (i == 1) {
      return 5;
    }

    if (i == 2) {
      return 3;
    }

    return i != 3 ? 0 : 4;
  }