コード例 #1
0
ファイル: PositionHelper.java プロジェクト: CubedCode/malmo
  public static List<BlockPos> getTouchingBlocks(EntityPlayerSP player) {
    // Determine which blocks we are touching.
    // This code is adapted from Entity, where it is used to fire the
    // Block.onEntityCollidedWithBlock methods.
    BlockPos blockposmin =
        new BlockPos(
            player.getEntityBoundingBox().minX - 0.001D,
            player.getEntityBoundingBox().minY - 0.001D,
            player.getEntityBoundingBox().minZ - 0.001D);
    BlockPos blockposmax =
        new BlockPos(
            player.getEntityBoundingBox().maxX + 0.001D,
            player.getEntityBoundingBox().maxY + 0.001D,
            player.getEntityBoundingBox().maxZ + 0.001D);
    List<BlockPos> blocks = new ArrayList<BlockPos>();

    if (player.worldObj.isAreaLoaded(blockposmin, blockposmax)) {
      for (int i = blockposmin.getX(); i <= blockposmax.getX(); ++i) {
        for (int j = blockposmin.getY(); j <= blockposmax.getY(); ++j) {
          for (int k = blockposmin.getZ(); k <= blockposmax.getZ(); ++k) {
            blocks.add(new BlockPos(i, j, k));
          }
        }
      }
    }
    return blocks;
  }
コード例 #2
0
  @Override
  public void onUpdate(EntityPlayerSP player) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    stats.tick++;

    if (stats.usingParachute && !player.capabilities.isFlying && !player.handleWaterMovement()) {
      player.motionY = -0.5D;
      player.motionX *= 0.5F;
      player.motionZ *= 0.5F;
    }
  }
コード例 #3
0
  @Override
  public void renderRedstoneInterfaceStuff(float partialTicks) {
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
    ItemStack itemStack = player.getCurrentEquippedItem();
    if (itemStack != null) {
      Item item = itemStack.getItem();

      if (item == ModItems.redstoneTool) {
        drawInterfaceLines(player, partialTicks);
        drawLinkingCube(itemStack, player, partialTicks);
      }
    }
  }
コード例 #4
0
ファイル: PacketCoinChange.java プロジェクト: WhiteGems/AE2
  public void onPacketReceived(Packet250CustomPayload packet, Player player) {
    DataInputStream dat = new DataInputStream(new ByteArrayInputStream(packet.data));
    BufferedReader buf = new BufferedReader(new InputStreamReader(dat));
    try {
      byte packetType = dat.readByte();
      boolean clearFirst = dat.readBoolean();
      boolean adding = dat.readBoolean();
      short length = dat.readShort();
      int coinAmount = dat.readInt();

      HashMap playerCoins = Aether.proxy.getClientCoins();

      if (clearFirst) {
        playerCoins.clear();
      }

      for (int i = 0; i < length; i++) {
        String username = dat.readUTF();
        if (adding) {
          playerCoins.put(username, Integer.valueOf(coinAmount));
          Aether.getClientPlayer((EntityPlayerSP) player).updateCoinAmount();
        } else {
          playerCoins.remove(username);
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #5
0
  @SideOnly(Side.CLIENT)
  private float getItemInUsePercentaje(EntityPlayerSP player, float speedFactor) {
    if (player.getItemInUse().getItem() instanceof WeaponBow) {
      WeaponBow bow = (WeaponBow) player.getItemInUse().getItem();

      float maxUse = bow.getFOVDuration(player.getItemInUse());
      float curUse = (float) player.getItemInUseCount();
      float percent = 0.0f;

      percent = maxUse - (maxUse - (bow.getMaxItemUseDuration(player.getItemInUse()) - curUse));
      percent *= (speedFactor * ((percent > 100) ? 1.0f : percent / 100.0f));
      percent = percent / maxUse;
      percent *= 1 + percent;

      return (percent > 1.0f) ? 1.0f : percent;
    } else {
      return 1.0f;
    }
  }
コード例 #6
0
  private void drawInterfaceLines(EntityPlayerSP player, float partialTicks) {
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldRenderer = tessellator.getWorldRenderer();

    double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;

    GlStateManager.pushAttrib();
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(10);
    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    Minecraft.getMinecraft().entityRenderer.disableLightmap();
    GlStateManager.pushMatrix();
    {
      worldRenderer.startDrawing(GL11.GL_LINES);
      worldRenderer.setColorOpaque(255, 0, 0);
      synchronized (TileEntityRedstoneInterface.interfaces) {
        for (TileEntityRedstoneInterface redstoneInterface :
            TileEntityRedstoneInterface.interfaces) {
          if (!redstoneInterface.isInvalid()) {
            BlockPos position = redstoneInterface.getPos();
            BlockPos target = redstoneInterface.getTarget();

            if (position.distanceSq(player.getPosition()) < 225) {
              if (target != null) {
                if (redstoneInterface.getWorld().isRemote) {
                  worldRenderer.addVertex(
                      target.getX() + 0.5 - playerX,
                      target.getY() + 0.5 - playerY,
                      target.getZ() + 0.5 - playerZ);
                  worldRenderer.addVertex(
                      position.getX() + 0.5 - playerX,
                      position.getY() + 0.5 - playerY,
                      position.getZ() + 0.5 - playerZ);
                }
              }
            }
          }
        }
      }
      tessellator.draw();
    }
    GlStateManager.popMatrix();
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GlStateManager.enableTexture2D();
    GlStateManager.popAttrib();
    Minecraft.getMinecraft().entityRenderer.enableLightmap();
  }
コード例 #7
0
ファイル: Portal.java プロジェクト: goeiecool9999/Portals
  @Override
  public void update() {
    AxisAlignedBB bbox =
        PortalgunMod.portalBlock
            .getCollisionBoundingBox(worldObj, this.getPos(), worldObj.getBlockState(this.getPos()))
            .expand(0, 1, 0.1);
    List<Entity> ents = worldObj.getEntitiesWithinAABB(Entity.class, bbox);

    for (Entity entityIn : ents) {
      Portal portal = this;
      if (portal.linked != null) {
        Vec3 thisPortal = new Vec3(pos.getX(), pos.getY(), pos.getZ());
        BlockPos otherPortalBP = portal.linked.getPos();
        Vec3 otherPortal =
            new Vec3(otherPortalBP.getX(), otherPortalBP.getY(), otherPortalBP.getZ());
        Vec3 diff = otherPortal.subtract(thisPortal);

        Vec3 newPos = entityIn.getPositionVector().add(diff);
        entityIn.motionZ = -entityIn.motionZ;
        entityIn.setLocationAndAngles(
            newPos.xCoord,
            newPos.yCoord,
            newPos.zCoord + 0.2,
            entityIn.getRotationYawHead() + 180,
            entityIn.rotationPitch);
        entityIn.prevRotationYaw = entityIn.rotationYaw;
        entityIn.prevRotationPitch = entityIn.rotationPitch;

        if (entityIn instanceof EntityPlayerSP) {
          EntityPlayerSP SPplayer = (EntityPlayerSP) entityIn;
          SPplayer.prevRenderArmYaw = SPplayer.renderArmYaw += 180;
          SPplayer.prevRotationYawHead = SPplayer.rotationYawHead += 180;
        }
      }
    }
  }
コード例 #8
0
  /**
   * this is a method for handling packets that were sent to the client.
   *
   * @param manager
   * @param packet
   * @param player
   * @param dat the data that it can read from
   * @param ID the packet ID
   */
  public void handleClientPacket(
      Packet packet, EntityPlayer player, ByteArrayDataInput dat, short ID) {
    EntityPlayer thePlayer = (EntityPlayer) player;
    World world = thePlayer.worldObj;

    if (world != null) {
      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiAPressurePlate) {
        if (ID == 1) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            ((EntityPlayerSP) thePlayer).closeScreen();
          }

          return;
        }

        if (ID == 2) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int allowedmobs = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            for (int var1 = 0; var1 < allowedmobs; var1++) {
              boolean bool = dat.readBoolean();
              GuiAPressurePlate.enabled[var1] = bool;
            }
          }

          return;
        }

        if (ID == 3) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.tpp.allowedPlayers.clear();
            int allowedPlayers = dat.readInt();
            {
              for (int var1 = 0; var1 < allowedPlayers; var1++) {
                short nameLength = dat.readShort();
                String username = "";

                for (int var2 = 0; var2 < nameLength; var2++) {
                  username = new StringBuilder().append(username).append(dat.readChar()).toString();
                }

                boolean bool = dat.readBoolean();
                GuiAPressurePlate.tpp.addPlayer(username);
                GuiAPressurePlate.tpp.setEnabledForPlayer(username, bool);
              }

              GuiAPressurePlate.lineUp();
            }
          }

          return;
        }

        if (ID == 4) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int index = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.switchbutton(index);
          }

          return;
        }

        if (ID == 11) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            if (GuiAPressurePlate.tpp.settings == null) {
              GuiAPressurePlate.tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= GuiAPressurePlate.tpp.settings.size()) {
                GuiAPressurePlate.tpp.setSetting(var3, dat.readBoolean());
              }
            }

            GuiAPressurePlate.LineUpSettings();
          }

          return;
        }

        if (ID == 10) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            int var2 = dat.readInt();

            if (GuiAPressurePlate.tpp.settings.size() >= var2) {
              GuiAPressurePlate.tpp.switchSetting(var2);
            }
          }

          return;
        }
      }

      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiModifyPressurePlate) {
        if (ID == 1) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            ((EntityPlayerSP) thePlayer).closeScreen();
          }
        }

        if (ID == 3) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.tpp.allowedPlayers.clear();
            int allowedPlayers = dat.readInt();
            {
              for (int var1 = 0; var1 < allowedPlayers; var1++) {
                short nameLength = dat.readShort();
                String username = "";

                for (int var2 = 0; var2 < nameLength; var2++) {
                  username = new StringBuilder().append(username).append(dat.readChar()).toString();
                }

                boolean bool = dat.readBoolean();
                GuiAPressurePlate.tpp.setEnabledForPlayer(username, bool);
              }

              GuiAPressurePlate.lineUp();
            }
          }

          return;
        }

        if (ID == 4) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int index = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.switchbutton(index);
          }

          return;
        }

        if (ID == 5) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            boolean bool = dat.readBoolean();
            int usernamelength = dat.readInt();
            String username = "";

            for (int var2 = 0; var2 < usernamelength; var2++) {
              char c = dat.readChar();
              username = new StringBuilder().append(username).append(c).toString();
            }

            if (thePlayer.getCommandSenderName().matches(username)) {
              if (bool) {
                GuiModifyPressurePlate.showText("Player added", 20);
              } else {
                GuiModifyPressurePlate.showText("Player is already in list", 20);
              }
            }
          }

          return;
        }

        if (ID == 6) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            boolean bool = dat.readBoolean();
            int usernamelength = dat.readInt();
            String username = "";

            for (int var2 = 0; var2 < usernamelength; var2++) {
              char c = dat.readChar();
              username = new StringBuilder().append(username).append(c).toString();
            }

            if (thePlayer.getCommandSenderName().matches(username)) {
              if (bool) {
                GuiModifyPressurePlate.showText("Player removed", 20);
              } else {
                GuiModifyPressurePlate.showText("Player is not in list", 20);
              }
            }
          }

          return;
        }

        if (ID == 10) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            int index = dat.readInt();

            if (GuiAPressurePlate.tpp.settings.size() >= index) {
              GuiAPressurePlate.tpp.switchSetting(index);
            }
          }

          return;
        }

        if (ID == 11) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            if (GuiAPressurePlate.tpp.settings == null) {
              GuiAPressurePlate.tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= GuiAPressurePlate.tpp.settings.size()) {
                GuiAPressurePlate.tpp.setSetting(var3, dat.readBoolean());
              }
            }

            GuiAPressurePlate.LineUpSettings();
          }

          return;
        }
      }

      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiPassword) {
        if (ID == 12) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int length = dat.readInt();
          StringBuilder sb = new StringBuilder();

          for (int var1 = 0; var1 < length; var1++) {
            sb.append(dat.readChar());
          }

          String name = sb.toString();

          if (((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp != null
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.xCoord
                  == coords[0]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.yCoord
                  == coords[1]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.zCoord
                  == coords[2]) {
            if (name.matches(thePlayer.getCommandSenderName())) {
              GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;
              gui.enterGui();
            }
          }

          return;
        }

        if (ID == 13) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          boolean b = dat.readBoolean();

          if (((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp != null
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.xCoord
                  == coords[0]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.yCoord
                  == coords[1]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.zCoord
                  == coords[2]) {
            GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;

            if (b) {
              gui.enterGui();
            } else {
              GuiPassword.showText("Wrong Password!!!", 20);
            }
          }

          return;
        }

        if (ID == 15) {
          return;
        }

        if (ID == 18) {
          int guiID = dat.readInt();

          if (FMLClientHandler.instance().getClient().currentScreen != null
              && FMLClientHandler.instance().getClient().currentScreen instanceof GuiPassword) {
            GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;
            gui.set = guiID;
          }

          return;
        }
      }

      if (ID == 7) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int itemId = dat.readInt();
        int stackSize = dat.readInt();
        int itemDamage = dat.readInt();
        int dimension = dat.readInt();

        if (!PPRegistry.getContainsPressurePlate(coords[0], coords[1], coords[2], dimension)) {
          PPRegistry.addPressurePlate(coords[0], coords[1], coords[2], dimension, false, null);
        }

        if (itemId == 0 && stackSize == 0 & itemDamage == 0) {
          if (tpp != null) {
            tpp.item[0] = null;
          }

          PPRegistry.setItem(coords[0], coords[1], coords[2], dimension, null);
          world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        } else {
          if (tpp != null) {
            tpp.item[0] = new ItemStack(Item.getItemById(itemId), stackSize, itemDamage);
          }

          PPRegistry.setItem(
              coords[0],
              coords[1],
              coords[2],
              dimension,
              new ItemStack(Item.getItemById(itemId), stackSize, itemDamage));
          world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        }

        return;
      }

      if (ID == 8) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te == null || !(te instanceof TileEntityPressurePlate)) {
          world.setTileEntity(coords[0], coords[1], coords[2], new TileEntityPressurePlate());
          tpp = (TileEntityPressurePlate) te;
        } else {
          tpp = (TileEntityPressurePlate) te;
        }

        if (tpp != null) {
          tpp.currentOutput = dat.readInt();
        }

        world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        return;
      }

      if (ID == 9) {
        PPRegistry.sendToServer = true;
        return;
      }

      if (ID == 11) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        if (tpp != null) {
          if (tpp.xCoord == coords[0] && tpp.yCoord == coords[1] && tpp.zCoord == coords[2]) {
            if (tpp.settings == null) {
              tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= tpp.settings.size()) {
                tpp.setSetting(var3, dat.readBoolean());
              }
            }
          }
        }

        return;
      }

      if (ID == 12) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        int length = dat.readInt();
        StringBuilder sb = new StringBuilder();

        for (int var1 = 0; var1 < length; var1++) {
          sb.append(dat.readChar());
        }

        sb.toString();
        return;
      }

      if (ID == 14) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        if (te != null || te instanceof TileEntityPressurePlate) {}

        int dimension = dat.readInt();

        if (!PPRegistry.getContainsPressurePlate(coords[0], coords[1], coords[2], dimension)) {
          PPRegistry.addPressurePlate(coords[0], coords[1], coords[2], dimension, false, null);
        }

        PPRegistry.setUsesPassword(coords[0], coords[1], coords[2], dimension, dat.readBoolean());
        return;
      }

      if (ID == 16) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int dimension = dat.readInt();

        if (tpp != null) {
          PPRegistry.removePressurePlate(tpp, dimension);
        }

        return;
      }

      if (ID == 17) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int dimension = dat.readInt();

        if (tpp != null) {
          PPRegistry.addPressurePlate(tpp, dimension);
        }

        return;
      }
      if (ID == 19) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        if (te instanceof TileEntityPressurePlate) {
          if (!(FMLClientHandler.instance().getClient().currentScreen
              instanceof GuiAPressurePlate)) {
            ((TileEntityPressurePlate) te).maxOutput = dat.readInt();
            ((TileEntityPressurePlate) te).itemsForMax = dat.readInt();
          } else if (GuiAPressurePlate.tpp != te || GuiAPressurePlate.hasData == false) {
            ((TileEntityPressurePlate) te).maxOutput = dat.readInt();
            ((TileEntityPressurePlate) te).itemsForMax = dat.readInt();
            GuiAPressurePlate.hasData = true;
          }
        }
      }
    }
  }
コード例 #9
0
  @Override
  public void onLivingUpdatePost(EntityPlayerSP player) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);

    if (player.worldObj.provider instanceof WorldProviderOrbit) {
      ((WorldProviderOrbit) player.worldObj.provider).postVanillaMotion(player);

      if (stats.inFreefall) {
        // No limb swing
        player.limbSwing -= player.limbSwingAmount;
        player.limbSwingAmount = player.prevLimbSwingAmount;
        float adjust = Math.min(Math.abs(player.limbSwing), Math.abs(player.limbSwingAmount) / 3);
        if (player.limbSwing < 0) player.limbSwing += adjust;
        else if (player.limbSwing > 0) player.limbSwing -= adjust;
        player.limbSwingAmount *= 0.9;
      } else {
        if (stats.inFreefallLast && this.downMot2 < -0.01D) {
          stats.landingTicks = 2 - (int) (Math.min(this.downMot2, stats.downMotionLast) * 75);
          if (stats.landingTicks > 6) stats.landingTicks = 6;
        }
      }

      if (stats.landingTicks > 0) stats.landingTicks--;
    } else stats.inFreefall = false;

    boolean ridingThirdPersonEntity =
        player.ridingEntity instanceof ICameraZoomEntity
            && ((ICameraZoomEntity) player.ridingEntity).defaultThirdPerson();

    if (ridingThirdPersonEntity && !stats.lastRidingCameraZoomEntity) {
      FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = 1;
    }

    if (player.ridingEntity != null && player.ridingEntity instanceof ICameraZoomEntity) {
      stats.lastZoomed = true;
      TickHandlerClient.zoom(((ICameraZoomEntity) player.ridingEntity).getCameraZoom());
    } else if (stats.lastZoomed) {
      stats.lastZoomed = false;
      TickHandlerClient.zoom(4.0F);
    }

    stats.lastRidingCameraZoomEntity = ridingThirdPersonEntity;

    if (stats.usingParachute) {
      player.fallDistance = 0.0F;
    }

    PlayerGearData gearData = ModelPlayerGC.getGearData(player);

    stats.usingParachute = false;

    if (gearData != null) {
      stats.usingParachute = gearData.getParachute() != null;
      if (gearData.getMask() >= 0) {
        player.height = 1.9375F;
      } else {
        player.height = 1.8F;
      }
      AxisAlignedBB bounds = player.getEntityBoundingBox();
      player.setEntityBoundingBox(
          new AxisAlignedBB(
              bounds.minX,
              bounds.minY,
              bounds.minZ,
              bounds.maxX,
              bounds.minY + (double) player.height,
              bounds.maxZ));
    }

    if (stats.usingParachute && player.onGround) {
      stats.setParachute(false);
      FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.thirdPersonView;
    }

    if (!stats.lastUsingParachute && stats.usingParachute) {
      FMLClientHandler.instance()
          .getClient()
          .getSoundHandler()
          .playSound(
              new PositionedSoundRecord(
                  new ResourceLocation(GalacticraftCore.TEXTURE_PREFIX + "player.parachute"),
                  0.95F + player.getRNG().nextFloat() * 0.1F,
                  1.0F,
                  (float) player.posX,
                  (float) player.posY,
                  (float) player.posZ));
    }

    stats.lastUsingParachute = stats.usingParachute;
    stats.lastOnGround = player.onGround;
  }
コード例 #10
0
  @Override
  public void onBuild(int i, EntityPlayerSP player) {
    // 0 : opened GC inventory tab
    // 1,2,3 : Compressor, CF, Standard Wrench
    // 4,5,6 : Fuel loader, Launchpad, NASA Workbench
    // 7: oil found 8: placed rocket

    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    int flag = stats.buildFlags;
    if (flag == -1) flag = 0;
    int repeatCount = flag >> 9;
    if (repeatCount <= 3) {
      repeatCount++;
    }
    if ((flag & 1 << i) > 0) return;
    flag |= 1 << i;
    stats.buildFlags = (flag & 511) + (repeatCount << 9);
    GalacticraftCore.packetPipeline.sendToServer(
        new PacketSimple(
            EnumSimplePacket.S_BUILDFLAGS_UPDATE,
            player.worldObj.provider.getDimensionId(),
            new Object[] {stats.buildFlags}));
    switch (i) {
      case 0:
      case 1:
      case 2:
      case 3:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help1")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/1"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/1"
                    + "\"}}]"));
        player.addChatMessage(
            new ChatComponentText(
                GCCoreUtil.translate("gui.message.help1a") + EnumColor.AQUA + " /gchelp"));
        break;
      case 4:
      case 5:
      case 6:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help2")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/2"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/2"
                    + "\"}}]"));
        break;
      case 7:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help3")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/oil"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/oil"
                    + "\"}}]"));
        break;
      case 8:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.prelaunch")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/pre"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/pre"
                    + "\"}}]"));
        break;
    }
  }
コード例 #11
0
  private void updateFeet(EntityPlayerSP player, double motionX, double motionZ) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    double motionSqrd = motionX * motionX + motionZ * motionZ;

    // If the player is on the moon, not airbourne and not riding anything
    if (motionSqrd > 0.001
        && player.worldObj != null
        && player.worldObj.provider instanceof WorldProviderMoon
        && player.ridingEntity == null
        && !player.capabilities.isFlying) {
      int iPosX = (int) Math.floor(player.posX);
      int iPosY = (int) Math.floor(player.posY - 1);
      int iPosZ = (int) Math.floor(player.posZ);
      BlockPos pos1 = new BlockPos(iPosX, iPosY, iPosZ);
      IBlockState state = player.worldObj.getBlockState(pos1);

      // If the block below is the moon block
      if (state.getBlock() == GCBlocks.blockMoon) {
        // And is the correct metadata (moon turf)
        if (state.getBlock().getMetaFromState(state) == 5) {
          // If it has been long enough since the last step
          if (stats.distanceSinceLastStep > 0.35) {
            Vector3 pos = new Vector3(player);
            // Set the footprint position to the block below and add random number to stop
            // z-fighting
            pos.y = MathHelper.floor_double(player.posY) + player.getRNG().nextFloat() / 100.0F;

            // Adjust footprint to left or right depending on step count
            switch (stats.lastStep) {
              case 0:
                pos.translate(
                    new Vector3(
                        Math.sin(Math.toRadians(-player.rotationYaw + 90)) * 0.25,
                        0,
                        Math.cos(Math.toRadians(-player.rotationYaw + 90)) * 0.25));
                break;
              case 1:
                pos.translate(
                    new Vector3(
                        Math.sin(Math.toRadians(-player.rotationYaw - 90)) * 0.25,
                        0,
                        Math.cos(Math.toRadians(-player.rotationYaw - 90)) * 0.25));
                break;
            }

            pos =
                WorldUtil.getFootprintPosition(
                    player.worldObj, player.rotationYaw - 180, pos, new BlockVec3(player));

            long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
            ClientProxyCore.footprintRenderer.addFootprint(
                chunkKey,
                player.worldObj.provider.getDimensionId(),
                pos,
                player.rotationYaw,
                player.getName());

            // Increment and cap step counter at 1
            stats.lastStep++;
            stats.lastStep %= 2;
            stats.distanceSinceLastStep = 0;
          } else {
            stats.distanceSinceLastStep += motionSqrd;
          }
        }
      }
    }
  }