コード例 #1
0
 @Override
 public void updateEntity() {
   if (drone != null && drone.isDead) {
     setDrone(null);
   }
   if (drone != null) {
     if (worldObj.isRemote) {
       double dx = drone.posX - (xCoord + 0.5);
       double dy = drone.posY - (yCoord + 0.5);
       double dz = drone.posZ - (zCoord + 0.5);
       float f3 = MathHelper.sqrt_double(dx * dx + dz * dz);
       rotationYaw = (float) -Math.atan2(dx, dz);
       rotationPitch = (float) -Math.atan2(dy, f3);
     } else {
       if (ringSendCooldown > 0) ringSendCooldown--;
       if (ringSendList.size() > 0 && ringSendCooldown <= 0) {
         ringSendCooldown = ringSendList.size() > 10 ? 1 : 5;
         NetworkHandler.sendToDimension(
             new PacketSpawnRing(
                 xCoord + 0.5, yCoord + 0.8, zCoord + 0.5, drone, ringSendList.remove(0)),
             worldObj.provider.dimensionId);
       }
     }
   }
 }
コード例 #2
0
 public void hack() {
   if (isInitialized() && isPlayerLookingAtTarget()) {
     IHackableEntity hackable =
         HackableHandler.getHackableForEntity(entity, PneumaticCraft.proxy.getPlayer());
     if (hackable != null
         && (hackTime == 0
             || hackTime > hackable.getHackTime(entity, PneumaticCraft.proxy.getPlayer())))
       NetworkHandler.sendToServer(new PacketHackingEntityStart(entity));
   }
 }
コード例 #3
0
 /**
  * Will initiate the wireframe rendering. When invoked on the server, it sends a packet to every
  * client to render the box.
  */
 @Override
 public void showRangeLines() {
   if (worldObj.isRemote) {
     rangeLineRenderer.resetRendering(getRange());
   } else {
     NetworkHandler.sendToAllAround(
         new PacketRenderRangeLines(this),
         worldObj,
         TileEntityConstants.PACKET_UPDATE_DISTANCE + getRange());
   }
 }
コード例 #4
0
 @Override
 public void onKeyTyped() {
   String[] elements = getDropdownElements();
   selectedElement = getWidget().getText();
   for (int i = 0; i < elements.length; i++) {
     if (elements[i].equals(selectedElement)) {
       NetworkHandler.sendToServer(new PacketSetGlobalVariable(getVariableName(), i));
       break;
     }
   }
 }
コード例 #5
0
 @Override
 public void overload() {
   for (int i = 0; i < 10; i++) {
     NetworkHandler.sendToAllAround(
         new PacketSpawnParticle(
             "largesmoke",
             xCoord + worldObj.rand.nextDouble(),
             yCoord + 1,
             zCoord + worldObj.rand.nextDouble(),
             0,
             0,
             0),
         worldObj);
   }
 }
コード例 #6
0
  private void update(EntityPlayer player) {
    for (ArmorMessage message : messageList) {
      message.getStat().update();
    }
    CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
    boolean helmetEnabled =
        GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked;
    if (comHudHandler.ticksExisted == 1) {
      for (IUpgradeRenderHandler handler : UpgradeRenderHandlerList.instance().upgradeRenderers) {
        handler.reset();
      }
      for (int i = 0; i < comHudHandler.upgradeRenderersEnabled.length; i++) {
        NetworkHandler.sendToServer(
            new PacketToggleHelmetFeature(
                (byte) i,
                helmetEnabled
                    && GuiKeybindCheckBox.trackedCheckboxes.get(
                            "pneumaticHelmet.upgrade."
                                + UpgradeRenderHandlerList.instance()
                                    .upgradeRenderers
                                    .get(i)
                                    .getUpgradeName())
                        .checked));
      }
    }
    if (comHudHandler.ticksExisted > comHudHandler.getStartupTime() && helmetEnabled) {
      for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
        IUpgradeRenderHandler upgradeRenderHandler =
            UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
        if (comHudHandler.upgradeRenderersInserted[i]
            && GuiKeybindCheckBox.trackedCheckboxes.get(
                    "pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName())
                .checked) {
          IGuiAnimatedStat stat = upgradeRenderHandler.getAnimatedStat();
          if (stat != null) {
            if (comHudHandler.helmetPressure > 0F) {
              stat.openWindow();
            } else {
              stat.closeWindow();
            }
            stat.update();
          }
          upgradeRenderHandler.update(player, comHudHandler.rangeUpgradesInstalled);
        }
      }
    }
    // clean the list
    for (int i = 0; i < messageList.size(); i++) {
      ArmorMessage message = messageList.get(i);
      if (message == null || --message.lifeSpan <= 0) {
        messageList.remove(i);
        i--;
      }
    }

    for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
      if (comHudHandler.ticksExisted
          == comHudHandler.getStartupTime()
              / (UpgradeRenderHandlerList.instance().upgradeRenderers.size() + 2)
              * (i + 1)) {
        player.worldObj.playSound(
            player.posX,
            player.posY,
            player.posZ,
            Sounds.HUD_INIT,
            0.1F,
            0.5F
                + (float) (i + 1)
                    / (UpgradeRenderHandlerList.instance().upgradeRenderers.size() + 2)
                    * 0.5F,
            true);
        boolean upgradeEnabled = comHudHandler.upgradeRenderersInserted[i];
        addMessage(
            new ArmorMessage(
                I18n.format(
                        "pneumaticHelmet.upgrade."
                            + UpgradeRenderHandlerList.instance()
                                .upgradeRenderers
                                .get(i)
                                .getUpgradeName())
                    + " "
                    + (upgradeEnabled ? "found" : "not installed"),
                new ArrayList<String>(),
                50,
                upgradeEnabled ? 0x7000AA00 : 0x70FF0000));
      }
    }

    if (comHudHandler.ticksExisted == 1) {
      player.worldObj.playSound(
          player.posX, player.posY, player.posZ, Sounds.HUD_INIT, 0.1F, 0.5F, true);
      addMessage(
          new ArmorMessage(
              "Initializing head-up display...", new ArrayList<String>(), 50, 0x7000AA00));
    }

    if (comHudHandler.ticksExisted == comHudHandler.getStartupTime()) {
      player.worldObj.playSound(
          player.posX, player.posY, player.posZ, Sounds.HUD_INIT_COMPLETE, 0.1F, 1.0F, true);
      addMessage(
          new ArmorMessage("Initialization complete!", new ArrayList<String>(), 50, 0x7000AA00));
    }
  }