예제 #1
0
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
  @Override
  public void checkStack(
      World par1World,
      int par2,
      int par3,
      int par4,
      Entity triggerer,
      ArrayList<ItemStack> stacks) {
    if (stacks.isEmpty()) {
      return;
    }

    if (this.arrayContainsEqualStack(stacks, new ItemStack(Item.firework))
        && this.arrayContainsEqualStack(stacks, new ItemStack(Item.fireballCharge))) {
      int index0 = this.arrayIndexOfStack(stacks, new ItemStack(Item.firework));
      int index1 = this.arrayIndexOfStack(stacks, new ItemStack(Item.fireballCharge));
      EnumFacing face = getFacing(par1World, par2, par3, par4);

      while (stacks.get(index0).stackSize > 0 && stacks.get(index1).stackSize > 0) {
        double d0 = par2 + (double) ((float) face.getFrontOffsetX() * 0.3F);
        double d1 = par3 + (double) ((float) face.getFrontOffsetX() * 0.3F);
        double d2 = par4 + (double) ((float) face.getFrontOffsetZ() * 0.3F);
        Random random = par1World.rand;
        double d3 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetX();
        double d4 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetY();
        double d5 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetZ();
        EntityFireball fireball = new EntityLargeFireball(par1World, d0, d1, d2, d3, d4, d5);
        par1World.spawnEntityInWorld(fireball);

        if (triggerer instanceof EntityLivingBase) {
          boolean shouldRun = true;
          if (triggerer instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) triggerer;
            if (player.capabilities.isCreativeMode) {
              // Remove the bellow comment to make the player in
              // creative mode not get launched
              // shouldRun = false;
            }
          }

          if (shouldRun) {
            triggerer.mountEntity(fireball);
          }
        }

        this.removeItemFromInventory(par1World, par2, par3, par4, new ItemStack(Item.firework, 1));
        stacks.get(index0).stackSize--;
        this.removeItemFromInventory(
            par1World, par2, par3, par4, new ItemStack(Item.fireballCharge, 1));
        stacks.get(index1).stackSize--;
      }
    }
  }
예제 #3
0
  /** Applies a velocity to each of the entities pushing them away from each other. Args: entity */
  public void applyEntityCollision(Entity entityIn) {
    if (!this.worldObj.isRemote) {
      if (!entityIn.noClip && !this.noClip) {
        if (entityIn != this.riddenByEntity) {
          if (entityIn instanceof EntityLivingBase
              && !(entityIn instanceof EntityPlayer)
              && !(entityIn instanceof EntityIronGolem)
              && this.getMinecartType() == EntityMinecart.EnumMinecartType.RIDEABLE
              && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D
              && this.riddenByEntity == null
              && entityIn.ridingEntity == null) {
            entityIn.mountEntity(this);
          }

          double d0 = entityIn.posX - this.posX;
          double d1 = entityIn.posZ - this.posZ;
          double d2 = d0 * d0 + d1 * d1;

          if (d2 >= 9.999999747378752E-5D) {
            d2 = (double) MathHelper.sqrt_double(d2);
            d0 = d0 / d2;
            d1 = d1 / d2;
            double d3 = 1.0D / d2;

            if (d3 > 1.0D) {
              d3 = 1.0D;
            }

            d0 = d0 * d3;
            d1 = d1 * d3;
            d0 = d0 * 0.10000000149011612D;
            d1 = d1 * 0.10000000149011612D;
            d0 = d0 * (double) (1.0F - this.entityCollisionReduction);
            d1 = d1 * (double) (1.0F - this.entityCollisionReduction);
            d0 = d0 * 0.5D;
            d1 = d1 * 0.5D;

            if (entityIn instanceof EntityMinecart) {
              double d4 = entityIn.posX - this.posX;
              double d5 = entityIn.posZ - this.posZ;
              Vec3 vec3 = (new Vec3(d4, 0.0D, d5)).normalize();
              Vec3 vec31 =
                  (new Vec3(
                          (double) MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F),
                          0.0D,
                          (double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F)))
                      .normalize();
              double d6 = Math.abs(vec3.dotProduct(vec31));

              if (d6 < 0.800000011920929D) {
                return;
              }

              double d7 = entityIn.motionX + this.motionX;
              double d8 = entityIn.motionZ + this.motionZ;

              if (((EntityMinecart) entityIn).getMinecartType()
                      == EntityMinecart.EnumMinecartType.FURNACE
                  && this.getMinecartType() != EntityMinecart.EnumMinecartType.FURNACE) {
                this.motionX *= 0.20000000298023224D;
                this.motionZ *= 0.20000000298023224D;
                this.addVelocity(entityIn.motionX - d0, 0.0D, entityIn.motionZ - d1);
                entityIn.motionX *= 0.949999988079071D;
                entityIn.motionZ *= 0.949999988079071D;
              } else if (((EntityMinecart) entityIn).getMinecartType()
                      != EntityMinecart.EnumMinecartType.FURNACE
                  && this.getMinecartType() == EntityMinecart.EnumMinecartType.FURNACE) {
                entityIn.motionX *= 0.20000000298023224D;
                entityIn.motionZ *= 0.20000000298023224D;
                entityIn.addVelocity(this.motionX + d0, 0.0D, this.motionZ + d1);
                this.motionX *= 0.949999988079071D;
                this.motionZ *= 0.949999988079071D;
              } else {
                d7 = d7 / 2.0D;
                d8 = d8 / 2.0D;
                this.motionX *= 0.20000000298023224D;
                this.motionZ *= 0.20000000298023224D;
                this.addVelocity(d7 - d0, 0.0D, d8 - d1);
                entityIn.motionX *= 0.20000000298023224D;
                entityIn.motionZ *= 0.20000000298023224D;
                entityIn.addVelocity(d7 + d0, 0.0D, d8 + d1);
              }
            } else {
              this.addVelocity(-d0, 0.0D, -d1);
              entityIn.addVelocity(d0 / 4.0D, 0.0D, d1 / 4.0D);
            }
          }
        }
      }
    }
  }
예제 #4
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1) {
      String var3 = par2ArrayOfStr[0];
      double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D;
      double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY;
      double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D;

      if (par2ArrayOfStr.length >= 4) {
        var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]);
        var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]);
        var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]);
      }

      World var10 = par1ICommandSender.getEntityWorld();

      if (!var10.blockExists((int) var4, (int) var6, (int) var8)) {
        notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]);
      } else {
        NBTTagCompound var11 = new NBTTagCompound();
        boolean var12 = false;

        if (par2ArrayOfStr.length >= 5) {
          IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4);

          try {
            NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText());

            if (!(var14 instanceof NBTTagCompound)) {
              notifyAdmins(
                  par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"});
              return;
            }

            var11 = (NBTTagCompound) var14;
            var12 = true;
          } catch (NBTException var17) {
            notifyAdmins(
                par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()});
            return;
          }
        }

        var11.setString("id", var3);
        Entity var18 = EntityList.createEntityFromNBT(var11, var10);

        if (var18 != null) {
          var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch);

          if (!var12 && var18 instanceof EntityLiving) {
            ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null);
          }

          var10.spawnEntityInWorld(var18);
          Entity var19 = var18;

          for (NBTTagCompound var15 = var11;
              var15.func_150297_b("Riding", 10);
              var15 = var15.getCompoundTag("Riding")) {
            Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10);

            if (var16 != null) {
              var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch);
              var10.spawnEntityInWorld(var16);
              var19.mountEntity(var16);
            }

            var19 = var16;
          }

          notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]);
        } else {
          notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]);
        }
      }
    } else {
      throw new WrongUsageException("commands.summon.usage", new Object[0]);
    }
  }
예제 #5
0
  @Override
  public void decodePacketdata(ByteBuf buffer) {
    super.decodePacketdata(buffer);
    this.fuelTank.setFluid(new FluidStack(GCFluids.fluidFuel, buffer.readInt()));
    this.landing = buffer.readBoolean();
    this.destinationFrequency = buffer.readInt();

    if (buffer.readBoolean()) {
      this.targetVec = new BlockPos(buffer.readInt(), buffer.readInt(), buffer.readInt());
    }

    this.motionX = buffer.readDouble() / 8000.0D;
    this.motionY = buffer.readDouble() / 8000.0D;
    this.motionZ = buffer.readDouble() / 8000.0D;
    this.lastMotionY = buffer.readDouble() / 8000.0D;
    this.lastLastMotionY = buffer.readDouble() / 8000.0D;

    if (this.cargoItems == null) {
      this.cargoItems = new ItemStack[this.getSizeInventory()];
    }

    this.setWaitForPlayer(buffer.readBoolean());

    this.statusMessage = ByteBufUtils.readUTF8String(buffer);
    this.statusMessage = this.statusMessage.equals("") ? null : this.statusMessage;
    this.statusMessageCooldown = buffer.readInt();
    this.lastStatusMessageCooldown = buffer.readInt();
    this.statusValid = buffer.readBoolean();

    // Update client with correct rider if needed
    if (this.worldObj.isRemote) {
      int shouldBeMountedId = buffer.readInt();
      if (this.riddenByEntity == null) {
        if (shouldBeMountedId > -1) {
          Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
          if (e != null) {
            if (e.dimension != this.dimension) {
              if (e instanceof EntityPlayer) {
                e =
                    WorldUtil.forceRespawnClient(
                        this.dimension,
                        e.worldObj.getDifficulty().getDifficultyId(),
                        e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(),
                        ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                e.mountEntity(this);
              }
            } else e.mountEntity(this);
          }
        }
      } else if (this.riddenByEntity.getEntityId() != shouldBeMountedId) {
        if (shouldBeMountedId == -1) {
          this.riddenByEntity.mountEntity(null);
        } else {
          Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
          if (e != null) {
            if (e.dimension != this.dimension) {
              if (e instanceof EntityPlayer) {
                e =
                    WorldUtil.forceRespawnClient(
                        this.dimension,
                        e.worldObj.getDifficulty().getDifficultyId(),
                        e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(),
                        ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                e.mountEntity(this);
              }
            } else e.mountEntity(this);
          }
        }
      }
    }
    this.statusColour = ByteBufUtils.readUTF8String(buffer);
    if (this.statusColour.equals("")) this.statusColour = null;
  }