コード例 #1
0
ファイル: EntityHooks.java プロジェクト: ayamitsu0321/GoreMod
  public static void onAttackEntityFrom(DamageSource damage, EntityLiving living) {
    if (living.getHealth() > 0 && living.hurtTime <= 0) {
      float f = 0.41F;

      if (living.canBleed() && living.canBleedByDamage(damage)) {
        Entity entity = damage.getEntity();

        if (GoreRegistry.containsFarDamage(damage.damageType)) {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        } else if (entity instanceof EntityPlayer) {
          ItemStack is = ((EntityPlayer) entity).getCurrentEquippedItem();

          if (living.canHurtByItem(is)) {
            f = 1.0F;
            living.isBleeding = true;
            living.ticksActuallyBleeding = 0;
            living.ticksNoBlood = 0;
            produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
          }
        } else {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        }
      }
    }
  }
コード例 #2
0
  public boolean shouldExecute() {
    if (this.entity.getAge() < 100
        && this.entity.getNavigator().noPath()
        && !this.entity.isInteracting()
        && this.entity.getRNG().nextInt(80) == 0) {
      if (this.entity.ai.npcInteracting && this.entity.getRNG().nextInt(4) == 1) {
        this.nearbyNPC = this.getNearbyNPC();
      }

      if (this.nearbyNPC != null) {
        this.xPosition = (double) MathHelper.floor_double(this.nearbyNPC.posX);
        this.yPosition = (double) MathHelper.floor_double(this.nearbyNPC.posY);
        this.zPosition = (double) MathHelper.floor_double(this.nearbyNPC.posZ);
        this.nearbyNPC.addInteract(this.entity);
      } else {
        Vec3 vec = this.getVec();
        if (vec == null) {
          return false;
        }

        this.xPosition = vec.xCoord;
        this.yPosition = vec.yCoord;
        this.zPosition = vec.zCoord;
      }

      return true;
    } else {
      return false;
    }
  }
コード例 #3
0
  /**
   * 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 f = this.getBrightness(1.0F);

      if (f > 0.5F
          && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F
          && this.worldObj.canBlockSeeSky(
              new BlockPos(
                  MathHelper.floor_double(this.posX),
                  MathHelper.floor_double(this.posY),
                  MathHelper.floor_double(this.posZ)))) {
        boolean flag = true;
        ItemStack itemstack = this.getEquipmentInSlot(4);

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

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

          flag = false;
        }
      }
    }

    super.onLivingUpdate();
  }
コード例 #4
0
 private boolean FlyToNearestWater() {
   int ai[] = ReturnNearestMaterialCoord(this, Material.water, Double.valueOf(20D));
   int i = ai[0];
   int j = ai[1];
   int k = ai[2];
   facePosition(i, j, k, 30F);
   if (j - MathHelper.floor_double(posY) > 2) {
     motionY += 0.14999999999999999D;
   }
   int l = 0;
   int i1 = 0;
   if (posX < (double) i) {
     l = i - MathHelper.floor_double(posX);
     motionX += 0.050000000000000003D;
   } else {
     l = MathHelper.floor_double(posX) - i;
     motionX -= 0.050000000000000003D;
   }
   if (posZ < (double) k) {
     i1 = k - MathHelper.floor_double(posZ);
     motionZ += 0.050000000000000003D;
   } else {
     i1 = MathHelper.floor_double(posX) - k;
     motionZ -= 0.050000000000000003D;
   }
   double d = l + i1;
   if (d < 3D) {
     return true;
   }
   return false;
 }
コード例 #5
0
  /** Place an entity in a nearby portal, creating one if necessary. */
  public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) {
    if (this.worldServerInstance.provider.dimensionId != 1) {
      if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) {
        this.makePortal(par1Entity);
        this.placeInExistingPortal(par1Entity, par2, par4, par6, par8);
      }
    } else {
      int i = MathHelper.floor_double(par1Entity.posX);
      int j = MathHelper.floor_double(par1Entity.posY) - 1;
      int k = MathHelper.floor_double(par1Entity.posZ);
      byte b0 = 1;
      byte b1 = 0;

      for (int l = -2; l <= 2; ++l) {
        for (int i1 = -2; i1 <= 2; ++i1) {
          for (int j1 = -1; j1 < 3; ++j1) {
            int k1 = i + i1 * b0 + l * b1;
            int l1 = j + j1;
            int i2 = k + i1 * b1 - l * b0;
            boolean flag = j1 < 0;
            this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.sandstone : Blocks.air);
          }
        }
      }

      par1Entity.setLocationAndAngles(
          (double) i, (double) j, (double) k, par1Entity.rotationYaw, 0.0F);
      par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
    }
  }
コード例 #6
0
ファイル: PathNavigate.java プロジェクト: JSut210/ModDev
  /** Gets the safe pathing Y position for the entity depending on if it can path swim or not */
  private int getPathableYPos() {
    if (this.theEntity.isInWater() && this.canSwim) {
      int var1 = (int) this.theEntity.boundingBox.minY;
      int var2 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.theEntity.posX),
              var1,
              MathHelper.floor_double(this.theEntity.posZ));
      int var3 = 0;

      do {
        if (var2 != Block.waterMoving.blockID && var2 != Block.waterStill.blockID) {
          return var1;
        }

        ++var1;
        var2 =
            this.worldObj.getBlockId(
                MathHelper.floor_double(this.theEntity.posX),
                var1,
                MathHelper.floor_double(this.theEntity.posZ));
        ++var3;
      } while (var3 <= 16);

      return (int) this.theEntity.boundingBox.minY;
    } else {
      return (int) (this.theEntity.boundingBox.minY + 0.5D);
    }
  }
コード例 #7
0
  /**
   * Adds velocity to push the entity out of blocks at the specified x, y, z position Args: x, y, z
   */
  protected boolean pushOutOfBlocks(double par1, double par3, double par5) {
    int i = MathHelper.floor_double(par1);
    int j = MathHelper.floor_double(par3);
    int k = MathHelper.floor_double(par5);
    double d3 = par1 - (double) i;
    double d4 = par5 - (double) k;

    if (this.isBlockTranslucent(i, j, k) || this.isBlockTranslucent(i, j + 1, k)) {
      boolean flag =
          !this.isBlockTranslucent(i - 1, j, k) && !this.isBlockTranslucent(i - 1, j + 1, k);
      boolean flag1 =
          !this.isBlockTranslucent(i + 1, j, k) && !this.isBlockTranslucent(i + 1, j + 1, k);
      boolean flag2 =
          !this.isBlockTranslucent(i, j, k - 1) && !this.isBlockTranslucent(i, j + 1, k - 1);
      boolean flag3 =
          !this.isBlockTranslucent(i, j, k + 1) && !this.isBlockTranslucent(i, j + 1, k + 1);
      byte b0 = -1;
      double d5 = 9999.0D;

      if (flag && d3 < d5) {
        d5 = d3;
        b0 = 0;
      }

      if (flag1 && 1.0D - d3 < d5) {
        d5 = 1.0D - d3;
        b0 = 1;
      }

      if (flag2 && d4 < d5) {
        d5 = d4;
        b0 = 4;
      }

      if (flag3 && 1.0D - d4 < d5) {
        d5 = 1.0D - d4;
        b0 = 5;
      }

      float f = 0.1F;

      if (b0 == 0) {
        this.motionX = (double) (-f);
      }

      if (b0 == 1) {
        this.motionX = (double) f;
      }

      if (b0 == 4) {
        this.motionZ = (double) (-f);
      }

      if (b0 == 5) {
        this.motionZ = (double) f;
      }
    }

    return false;
  }
コード例 #8
0
ファイル: EntityIronGolem.java プロジェクト: leijurv/MineBot
  /**
   * 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() {
    super.onLivingUpdate();

    if (this.attackTimer > 0) {
      --this.attackTimer;
    }

    if (this.holdRoseTick > 0) {
      --this.holdRoseTick;
    }

    if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D
        && this.rand.nextInt(5) == 0) {
      int i = MathHelper.floor_double(this.posX);
      int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
      int k = MathHelper.floor_double(this.posZ);
      IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k));
      Block block = iblockstate.getBlock();

      if (block.getMaterial() != Material.air) {
        this.worldObj.spawnParticle(
            EnumParticleTypes.BLOCK_CRACK,
            this.posX + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            this.getEntityBoundingBox().minY + 0.1D,
            this.posZ + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            4.0D * ((double) this.rand.nextFloat() - 0.5D),
            0.5D,
            ((double) this.rand.nextFloat() - 0.5D) * 4.0D,
            new int[] {Block.getStateId(iblockstate)});
      }
    }
  }
コード例 #9
0
 public S11PacketSpawnExperienceOrb(EntityXPOrb p_i45167_1_) {
   this.field_148992_a = p_i45167_1_.getEntityId();
   this.field_148990_b = MathHelper.floor_double(p_i45167_1_.posX * 32.0D);
   this.field_148991_c = MathHelper.floor_double(p_i45167_1_.posY * 32.0D);
   this.field_148988_d = MathHelper.floor_double(p_i45167_1_.posZ * 32.0D);
   this.field_148989_e = p_i45167_1_.getXpValue();
 }
コード例 #10
0
  private void setNewWayPoint(SSEntityScriptedSurvivor ess) {
    boolean flag = false;
    int j = -1;
    int k = -1;
    int l = -1;
    float f2 = -99999F;
    ess.coords = null;
    for (int i1 = 0; i1 < 10; i1++) {
      int j1 = MathHelper.floor_double((ess.posX + (double) ess.getRNG().nextInt(21)) - 10D);
      int k1 = MathHelper.floor_double((ess.posY + (double) ess.getRNG().nextInt(7)) - 3D);
      int l1 = MathHelper.floor_double((ess.posZ + (double) ess.getRNG().nextInt(21)) - 10D);
      float f3 = isTargetBlock(ess, j1, k1, l1) ? 1000F : (float) ess.getDistance(j1, k1, l1);
      if (f3 == 1000F) {
        j = j1;
        k = k1;
        l = l1;
        ess.coords = new int[3];
        ess.coords[0] = j;
        ess.coords[1] = k;
        ess.coords[2] = l;
        flag = true;
        break;
      } else if (f3 > f2) {
        f2 = f3;
        j = j1;
        k = k1;
        l = l1;
        flag = true;
      }
    }

    if (flag) {
      ess.path = ess.worldObj.getEntityPathToXYZ(ess, j, k, l, 18F);
    }
  }
コード例 #11
0
  private void checkNearbyBlocks(SSEntityScriptedSurvivor ess) {
    int i = MathHelper.floor_double(ess.posX);
    int j = MathHelper.floor_double(ess.boundingBox.minY);
    int k = MathHelper.floor_double(ess.posZ);
    boolean flag = true;
    if (isTargetBlock(ess, i, j - 1, k)) {
      j--;
    } else if (isTargetBlock(ess, i, j + 2, k)) {
      j += 2;
    } else if (isTargetBlock(ess, i - 1, j, k)) {
      i--;
    } else if (isTargetBlock(ess, i, j, k - 1)) {
      k--;
    } else if (isTargetBlock(ess, i + 1, j, k)) {
      i++;
    } else if (isTargetBlock(ess, i, j, k + 1)) {
      k++;
    } else flag = false;

    if (flag) {
      ess.coords = new int[3];
      ess.coords[0] = i;
      ess.coords[1] = j;
      ess.coords[2] = k;
      ess.path = ess.worldObj.getEntityPathToXYZ(ess, i, j, k, 12F);
    }
  }
コード例 #12
0
ファイル: BlockTrap.java プロジェクト: WhiteGems/AE2
  /** Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity */
  public void onEntityWalking(World var1, int var2, int var3, int var4, Entity var5) {
    if (var5 instanceof EntityPlayer) {
      var1.playSoundEffect(
          (double) ((float) var2 + 0.5F),
          (double) ((float) var3 + 0.5F),
          (double) ((float) var4 + 0.5F),
          "aemisc.activateTrap",
          1.0F,
          1.0F);
      int var6 = MathHelper.floor_double((double) var2);
      int var7 = MathHelper.floor_double((double) var3);
      int var8 = MathHelper.floor_double((double) var4);

      if (!var1.isRemote) {
        switch (var1.getBlockMetadata(var2, var3, var4)) {
          case 0:
            EntitySentry var9 = new EntitySentry(var1);
            var9.setPosition((double) var6 + 0.5D, (double) var7 + 1.5D, (double) var8 + 0.5D);
            var1.spawnEntityInWorld(var9);

          case 1:
        }
      }

      var1.setBlock(
          var2,
          var3,
          var4,
          AetherBlocks.LockedDungeonStone.blockID,
          var1.getBlockMetadata(var2, var3, var4),
          2);
    }
  }
コード例 #13
0
  /** Called when the mob is falling. Calculates and applies fall damage. */
  protected void fall(float distance) {
    if (distance > 1.0F) {
      this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int(distance * 0.5F - 3.0F);

    if (i > 0) {
      this.attackEntityFrom(DamageSource.fall, (float) i);

      if (this.riddenByEntity != null) {
        this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float) i);
      }

      Block block =
          this.worldObj.getBlock(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY - 0.2D - (double) this.prevRotationYaw),
              MathHelper.floor_double(this.posZ));

      if (block.getMaterial() != Material.air) {
        Block.SoundType soundtype = block.stepSound;
        this.worldObj.playSoundAtEntity(
            this,
            soundtype.getStepSound(),
            soundtype.getVolume() * 0.5F,
            soundtype.getFrequency() * 0.75F);
      }
    }
  }
コード例 #14
0
  /** Time remaining during which the Animal is sped up and flees. */
  protected void updateWanderPath() {
    this.worldObj.theProfiler.startSection("stroll");
    boolean flag = false;
    int i = -1;
    int j = -1;
    int k = -1;
    float f = -99999.0F;

    for (int l = 0; l < 10; ++l) {
      int i1 = MathHelper.floor_double(this.posX + (double) this.rand.nextInt(13) - 6.0D);
      int j1 = MathHelper.floor_double(this.posY + (double) this.rand.nextInt(7) - 3.0D);
      int k1 = MathHelper.floor_double(this.posZ + (double) this.rand.nextInt(13) - 6.0D);
      float f1 = this.getBlockPathWeight(i1, j1, k1);

      if (f1 > f) {
        f = f1;
        i = i1;
        j = j1;
        k = k1;
        flag = true;
      }
    }

    if (flag) {
      this.pathToEntity =
          this.worldObj.getEntityPathToXYZ(this, i, j, k, 10.0F, true, false, false, true);
    }

    this.worldObj.theProfiler.endSection();
  }
コード例 #15
0
  public static Fluid getFluid(EntityItem item, boolean below) {
    double d0 = item.posY + (double) item.getEyeHeight();
    int i = MathHelper.floor_double(item.posX);
    int j = MathHelper.floor_float((float) MathHelper.floor_double(d0));
    if (below) j--;
    int k = MathHelper.floor_double(item.posZ);
    Block block = item.worldObj.getBlock(i, j, k);

    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null && block instanceof IFluidBlock) fluid = ((IFluidBlock) block).getFluid();
    else if (block instanceof BlockLiquid) fluid = FluidRegistry.WATER;

    if (below) return fluid;

    double filled = 1.0f; // If it's not a liquid assume it's a solid block
    if (block instanceof IFluidBlock) {
      filled = ((IFluidBlock) block).getFilledPercentage(item.worldObj, i, j, k);
    }

    if (filled < 0) {
      filled *= -1;
      // filled -= 0.11111111F; //Why this is needed.. not sure...
      if (d0 > (double) (j + (1 - filled))) return fluid;
    } else {
      if (d0 < (double) (j + filled)) return fluid;
    }
    return null;
  }
コード例 #16
0
        @Override
        /**
         * Updates the task
         */
        public void updateTask()
        {
            Random random = this.field_179473_a.getRNG();
            World world = this.field_179473_a.worldObj;
            int i = MathHelper.floor_double(this.field_179473_a.posX - 2.0D + random.nextDouble() * 4.0D);
            int j = MathHelper.floor_double(this.field_179473_a.posY + random.nextDouble() * 3.0D);
            int k = MathHelper.floor_double(this.field_179473_a.posZ - 2.0D + random.nextDouble() * 4.0D);
            BlockPos blockpos = new BlockPos(i, j, k);
            IBlockState iblockstate = world.getBlockState(blockpos);
            Block block = iblockstate.getBlock();

            if (EntityChaoticEnderman.carriableBlocks.contains(block))
            {
            	int blockMeta = ModBlocks.chaos_Block.getMetaFromState(iblockstate);
            	if (block != ModBlocks.chaos_Block || (blockMeta < 4)) {
            		this.field_179473_a.func_175490_a(iblockstate);
            		world.setBlockState(blockpos, Blocks.air.getDefaultState());
            	} else
            		this.field_179473_a.func_175490_a(ModBlocks.chaos_Block.getStateFromMeta((world.rand.nextFloat() >= 0.2F ?
            			13 : 14) + blockMeta < 2 ? 0 : 1));
            }
        }
コード例 #17
0
  /**
   * Places a line of the specified block ID into the world from the first coordinate triplet to the
   * second.
   */
  private void placeBlockLine(int[] par1ArrayOfInteger, int[] par2ArrayOfInteger, Block par3) {
    int[] var4 = new int[] {0, 0, 0};
    byte var5 = 0;
    byte var6;

    for (var6 = 0; var5 < 3; ++var5) {
      var4[var5] = par2ArrayOfInteger[var5] - par1ArrayOfInteger[var5];
      if (Math.abs(var4[var5]) > Math.abs(var4[var6])) var6 = var5;
    }

    if (var4[var6] != 0) {
      byte var7 = OTHER_COORD_PAIRS[var6];
      byte var8 = OTHER_COORD_PAIRS[var6 + 3];
      byte var9;

      if (var4[var6] > 0) var9 = 1;
      else var9 = -1;

      double var10 = (double) var4[var7] / (double) var4[var6];
      double var12 = (double) var4[var8] / (double) var4[var6];
      int[] var14 = new int[] {0, 0, 0};
      int var15 = 0;

      for (int var16 = var4[var6] + var9; var15 != var16; var15 += var9) {
        var14[var6] = MathHelper.floor_double(par1ArrayOfInteger[var6] + var15 + 0.5D);
        var14[var7] = MathHelper.floor_double(par1ArrayOfInteger[var7] + var15 * var10 + 0.5D);
        var14[var8] = MathHelper.floor_double(par1ArrayOfInteger[var8] + var15 * var12 + 0.5D);
        if (worldObj.isAirBlock(var14[0], var14[1], var14[2])
            || worldObj.getBlock(var14[0], var14[1], var14[2]) == TFCBlocks.leaves
            || worldObj.getBlock(var14[0], var14[1], var14[2]) == TFCBlocks.leaves2) {
          this.setBlockAndNotifyAdequately(
              this.worldObj, var14[0], var14[1], var14[2], par3, treeId);
        }
      }
      if (par1ArrayOfInteger[0] == par2ArrayOfInteger[0]
          && par1ArrayOfInteger[2] == par2ArrayOfInteger[2]
          && par1ArrayOfInteger[1] < par2ArrayOfInteger[1]) {
        for (int i = -1; i < 2; i++) {
          for (int k = -1; k < 2; k++) {
            if (rand.nextBoolean()
                && par1ArrayOfInteger[1] > 1
                && Math.abs(i) != Math.abs(k)
                && !worldObj.isAirBlock(
                    i + par1ArrayOfInteger[0],
                    par1ArrayOfInteger[1] - 1,
                    par1ArrayOfInteger[2] + k)) {
              this.setBlockAndNotifyAdequately(
                  this.worldObj,
                  i + par1ArrayOfInteger[0],
                  par1ArrayOfInteger[1],
                  par1ArrayOfInteger[2] + k,
                  par3,
                  treeId);
            }
          }
        }
      }
    }
  }
コード例 #18
0
 @Override
 public boolean getCanSpawnHere() {
   return rand.nextInt(5) == 0
       && worldObj.canBlockSeeTheSky(
           MathHelper.floor_double(posX),
           MathHelper.floor_double(posY) + 1,
           MathHelper.floor_double(posZ));
 }
コード例 #19
0
ファイル: PathNavigate.java プロジェクト: JSut210/ModDev
 /** Try to find and set a path to XYZ. Returns true if successful. */
 public boolean tryMoveToXYZ(double par1, double par3, double par5, float par7) {
   PathEntity var8 =
       this.getPathToXYZ(
           (double) MathHelper.floor_double(par1),
           (double) ((int) par3),
           (double) MathHelper.floor_double(par5));
   return this.setPath(var8, par7);
 }
コード例 #20
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    int x = MathHelper.floor_double(posX);
    int y = MathHelper.floor_double(posY);
    int z = MathHelper.floor_double(posZ);
    worldObj.setBlock(x, y, z, Blocks.fire);
  }
コード例 #21
0
ファイル: EntityNPC.java プロジェクト: briman0094/Pixelmon
  @Override
  public boolean getCanSpawnHere() {
    int var1 = MathHelper.floor_double(this.posX);
    int var2 = MathHelper.floor_double(this.boundingBox.minY);
    int var3 = MathHelper.floor_double(this.posZ);

    int blockId = this.worldObj.getBlockId(var1, var2 - 1, var3);
    return blockId == Block.grass.blockID || blockId == Block.sand.blockID;
  }
コード例 #22
0
ファイル: EntityAnimal.java プロジェクト: McSwede/XIV
 /** Checks if the entity's current position is a valid location to spawn this entity. */
 public boolean getCanSpawnHere() {
   int var1 = MathHelper.floor_double(this.posX);
   int var2 = MathHelper.floor_double(this.getEntityBoundingBox().minY);
   int var3 = MathHelper.floor_double(this.posZ);
   BlockPos var4 = new BlockPos(var1, var2, var3);
   return this.worldObj.getBlockState(var4.offsetDown()).getBlock() == this.field_175506_bl
       && this.worldObj.getLight(var4) > 8
       && super.getCanSpawnHere();
 }
コード例 #23
0
 private boolean checkPlayerWater(EntityPlayer thePlayer) {
   if (thePlayer.isInWater()) {
     int x = MathHelper.floor_double(thePlayer.posX + 0.5D);
     int y = MathHelper.floor_double(thePlayer.posY + thePlayer.getEyeHeight());
     int z = MathHelper.floor_double(thePlayer.posZ + 0.5D);
     return thePlayer.worldObj.getBlock(x, y, z).getMaterial() == Material.water;
   }
   return false;
 }
コード例 #24
0
  @Override
  protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
    NewDimData dimension;
    DungeonHelper dungeonHelper = DungeonHelper.instance();

    if (command.length > 1) {
      return DDCommandResult.TOO_MANY_ARGUMENTS;
    }

    DimLink link;
    DungeonData result;
    int x = MathHelper.floor_double(sender.posX);
    int y = MathHelper.floor_double(sender.posY);
    int z = MathHelper.floor_double(sender.posZ);
    int orientation =
        MathHelper.floor_double((sender.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;

    if (command.length == 0) {
      dimension = PocketManager.getDimensionData(sender.worldObj);
      link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);

      sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift, 0, 3);
      sendChat(sender, "Created a rift to a random dungeon.");
    } else {
      result = getRandomDungeonByPartialName(command[0], dungeonHelper.getRegisteredDungeons());
      if (result == null) {
        result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
      }

      // Check if we found any matches
      if (result != null) {
        dimension = PocketManager.getDimensionData(sender.worldObj);
        link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);

        if (PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result)) {
          // Create a rift to our selected dungeon and notify the player
          sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift, 0, 3);
          sendChat(
              sender,
              "Created a rift to \""
                  + result.schematicName()
                  + "\" dungeon (Dimension ID = "
                  + link.destination().getDimension()
                  + ").");
        } else {
          // Dungeon generation failed somehow. Notify the user and remove the useless link.
          dimension.deleteLink(link);
          sendChat(sender, "Dungeon generation failed unexpectedly!");
        }
      } else {
        // No matches!
        return new DDCommandResult(
            "Error: The specified dungeon was not found. Use 'list' to see a list of the available dungeons.");
      }
    }
    return DDCommandResult.SUCCESS;
  }
コード例 #25
0
ファイル: EntityMinecart.java プロジェクト: leijurv/MineBot
  public Vec3 func_70489_a(double p_70489_1_, double p_70489_3_, double p_70489_5_) {
    int i = MathHelper.floor_double(p_70489_1_);
    int j = MathHelper.floor_double(p_70489_3_);
    int k = MathHelper.floor_double(p_70489_5_);

    if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k))) {
      --j;
    }

    IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k));

    if (BlockRailBase.isRailBlock(iblockstate)) {
      BlockRailBase.EnumRailDirection blockrailbase$enumraildirection =
          (BlockRailBase.EnumRailDirection)
              iblockstate.getValue(((BlockRailBase) iblockstate.getBlock()).getShapeProperty());
      int[][] aint = matrix[blockrailbase$enumraildirection.getMetadata()];
      double d0 = 0.0D;
      double d1 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
      double d2 = (double) j + 0.0625D + (double) aint[0][1] * 0.5D;
      double d3 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
      double d4 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
      double d5 = (double) j + 0.0625D + (double) aint[1][1] * 0.5D;
      double d6 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
      double d7 = d4 - d1;
      double d8 = (d5 - d2) * 2.0D;
      double d9 = d6 - d3;

      if (d7 == 0.0D) {
        p_70489_1_ = (double) i + 0.5D;
        d0 = p_70489_5_ - (double) k;
      } else if (d9 == 0.0D) {
        p_70489_5_ = (double) k + 0.5D;
        d0 = p_70489_1_ - (double) i;
      } else {
        double d10 = p_70489_1_ - d1;
        double d11 = p_70489_5_ - d3;
        d0 = (d10 * d7 + d11 * d9) * 2.0D;
      }

      p_70489_1_ = d1 + d7 * d0;
      p_70489_3_ = d2 + d8 * d0;
      p_70489_5_ = d3 + d9 * d0;

      if (d8 < 0.0D) {
        ++p_70489_3_;
      }

      if (d8 > 0.0D) {
        p_70489_3_ += 0.5D;
      }

      return new Vec3(p_70489_1_, p_70489_3_, p_70489_5_);
    } else {
      return null;
    }
  }
コード例 #26
0
  public S2CPacketSpawnGlobalEntity(Entity p_i45191_1_) {
    this.field_149059_a = p_i45191_1_.getEntityId();
    this.field_149057_b = MathHelper.floor_double(p_i45191_1_.posX * 32.0D);
    this.field_149058_c = MathHelper.floor_double(p_i45191_1_.posY * 32.0D);
    this.field_149055_d = MathHelper.floor_double(p_i45191_1_.posZ * 32.0D);

    if (p_i45191_1_ instanceof EntityLightningBolt) {
      this.field_149056_e = 1;
    }
  }
コード例 #27
0
 public Collection<TileEntityCrystalPylon> getNearbyPylons(
     World world, double x, double y, double z, CrystalElement e, int range, boolean LOS) {
   return this.getNearbyPylons(
       world,
       MathHelper.floor_double(x),
       MathHelper.floor_double(y),
       MathHelper.floor_double(z),
       e,
       range,
       LOS);
 }
コード例 #28
0
ファイル: Util.java プロジェクト: Tsuteto/AppleMilkTea_1.6.X
  // 現在地のバイオームを確認。
  // 複数のクラスで利用するので、ここにまとめた。
  public static BiomeGenBase checkCurrentBiome(World world, EntityPlayer player) {
    BiomeGenBase biome = BiomeGenBase.plains;

    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);

    biome = world.getBiomeGenForCoords(x, z);

    return biome;
  }
コード例 #29
0
ファイル: EntityDartPhoenix.java プロジェクト: WhiteGems/AE2
 public boolean onHitBlock() {
   this.curvature = 0.03F;
   int var1 = MathHelper.floor_double(this.posX);
   int var2 = MathHelper.floor_double(this.posY);
   int var3 = MathHelper.floor_double(this.posZ);
   this.worldObj.setBlock(var1, var2, var3, 51);
   this.worldObj.playSoundAtEntity(
       this, "random.drr", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
   this.setDead();
   return this.victim == null;
 }
コード例 #30
0
 @Override
 @SideOnly(Side.CLIENT)
 public final int getRenderColor(int dmg) {
   // return Color.HSBtoRGB(((System.currentTimeMillis()/60)%360)/360F, 0.8F, 1);
   World world = Minecraft.getMinecraft().theWorld;
   EntityPlayer ep = Minecraft.getMinecraft().thePlayer;
   int x = MathHelper.floor_double(ep.posX);
   int y = MathHelper.floor_double(ep.posY + ep.getEyeHeight());
   int z = MathHelper.floor_double(ep.posZ);
   return this.colorMultiplier(world, x, y, z);
 }