示例#1
0
  public static boolean areAllPlayersSlowMotion(World world) {
    List<EntityPlayer> players = world.playerEntities;
    boolean flag = true;

    for (EntityPlayer player : players) {
      if (!DataManager.getIsSpeeding(player)
          || !canRunSuperSpeed(player)
          || !DataManager.getInSlowMotion(player)
          || !player.isEntityAlive()) {
        flag = false;
      }
    }

    return flag;
  }
示例#2
0
  @Override
  public void updateScreen() {
    if (mc.theWorld.getWorldTime() % 10L == 3 || forced) {
      forced = false;
      players.clear();
      for (int i = 0; i < mc.theWorld.playerEntities.size(); i++) {
        EntityPlayer player = (EntityPlayer) mc.theWorld.playerEntities.get(i);
        if (player == mc.thePlayer) {
          continue;
        }
        if (player.isEntityAlive()
            && !players.contains(player.getCommandSenderName())
            && player.getDistanceToEntity(mc.thePlayer) < 16D
            && player.canEntityBeSeen(mc.thePlayer)) {
          players.add(player.getCommandSenderName());
        }
      }
      Collections.sort(players);

      buttonList.clear();

      for (int i = 0; i < players.size(); i++) {
        if (i == 12) {
          break;
        }
        buttonList.add(
            new GuiButton(
                i,
                guiLeft + 6 + (i % 2 == 1 ? 84 : 0),
                guiTop + 4 + 22 * (int) Math.floor((double) i / 2D),
                80,
                20,
                players.get(i)));
      }

      buttonList.add(
          new GuiButton(
              ID_CANCEL,
              width / 2 - 45,
              guiTop + ySize - 31,
              90,
              20,
              StatCollector.translateToLocal("gui.cancel")));
    }
  }
  @SubscribeEvent
  public void onTick(TickEvent.ClientTickEvent tick) {
    if (lastWorld != FMLClientHandler.instance().getClient().theWorld
        || thePlayer != FMLClientHandler.instance().getClient().thePlayer) {
      thePlayer = FMLClientHandler.instance().getClient().thePlayer;
      if (thePlayer != null) {
        lastWorld = thePlayer.worldObj;
      } else {
        lastWorld = null;
      }
    }

    if (thePlayer != null && thePlayer.isEntityAlive() && !DynamicLights.globalLightsOff()) {
      List<IMCMessage> messages = FMLInterModComms.fetchRuntimeMessages(this);
      if (messages.size() > 0) {
        // just get the last one
        IMCMessage imcMessage = messages.get(messages.size() - 1);
        if (imcMessage.key.equalsIgnoreCase("forceplayerlighton")) {
          if (!fmlOverrideEnable) {
            fmlOverrideEnable = true;
            if (!enabled) {
              lightLevel = 15;
              enableLight();
            }
          }
        } else if (imcMessage.key.equalsIgnoreCase("forceplayerlightoff")) {
          if (fmlOverrideEnable) {
            fmlOverrideEnable = false;
            if (enabled) {
              disableLight();
            }
          }
        }
      }

      if (!fmlOverrideEnable) {
        int prevLight = lightLevel;

        ItemStack item = thePlayer.getCurrentEquippedItem();
        lightLevel = itemsMap.getLightFromItemStack(item);

        for (ItemStack armor : thePlayer.inventory.armorInventory) {
          lightLevel = DynamicLights.maxLight(lightLevel, itemsMap.getLightFromItemStack(armor));
        }

        if (prevLight != 0 && lightLevel != prevLight) {
          lightLevel = 0;
        } else {
          if (thePlayer.isBurning()) {
            lightLevel = 15;
          } else {
            if (checkPlayerWater(thePlayer)
                && item != null
                && notWaterProofItems.retrieveValue(
                        GameData.getItemRegistry().getNameForObject(item.getItem()),
                        item.getItemDamage())
                    == 1) {
              lightLevel = 0;

              for (ItemStack armor : thePlayer.inventory.armorInventory) {
                if (armor != null
                    && notWaterProofItems.retrieveValue(
                            GameData.getItemRegistry().getNameForObject(armor.getItem()),
                            item.getItemDamage())
                        == 0) {
                  lightLevel =
                      DynamicLights.maxLight(lightLevel, itemsMap.getLightFromItemStack(armor));
                }
              }
            }
          }
        }

        if (!enabled && lightLevel > 0) {
          enableLight();
        } else if (enabled && lightLevel < 1) {
          disableLight();
        }
      }
    }
  }
  @Override
  public void onInventoryChanged() {
    super.onInventoryChanged();

    if (!this.worldObj.isRemote) {
      this.rotateCraftingGrid();

      this.inventory[this.getSizeInventory()] =
          CraftingManager.getInstance()
              .findMatchingRecipe(this.container.craftMatrix, this.worldObj);

      if (CraftingPillars.modThaumcraft) {
        if (this.worldObj.loadedEntityList != null) {
          float closest = Float.MAX_VALUE;
          for (int i = 0; i < this.worldObj.loadedEntityList.size(); i++) {
            if (this.worldObj.loadedEntityList.get(i) instanceof EntityPlayer) {
              EntityPlayer currentPlayer = (EntityPlayer) this.worldObj.loadedEntityList.get(i);
              if (currentPlayer.isEntityAlive()) {
                float distance =
                    (float) currentPlayer.getDistanceSq(this.xCoord, this.yCoord, this.zCoord);
                if (distance < closest) {
                  closest = distance;
                  this.closestPlayer = currentPlayer;
                }
              }
            }
          }
        }

        //				if(this.closestPlayer != null && this.getStackInSlot(10) != null)
        //				{
        //					ItemStack result =
        // CraftingPillarsAPIHelper.findMatchingArcaneRecipe(this.container.craftMatrix,
        // this.closestPlayer);
        //					if(result != null)
        //					{
        //						FMLLog.warning("Result " + result.getDisplayName());
        //
        //						this.inventory[this.getSizeInventory()] = result;
        //						aspectsForRecipe =
        // CraftingPillarsAPIHelper.findMatchingArcaneRecipeAspects(this.container.craftMatrix,
        // this.closestPlayer);
        //
        //						for(int i = 0; i < aspectsForRecipe.size(); i++)
        //						{
        //							FMLLog.warning(aspectsForRecipe.getAspects()[i].getName() + ": " +
        // aspectsForRecipe.getAmount(aspectsForRecipe.getAspects()[i]));
        //						}
        //
        //					}
        //					else {
        //						FMLLog.warning("no Result");
        //
        ////						aspects = null;
        //					}
        //				}

      }
      CraftingPillars.proxy.sendToPlayers(
          this.getDescriptionPacket(), this.worldObj, this.xCoord, this.yCoord, this.zCoord, 64);
    }
  }
  @SubscribeEvent
  public void sleepInBed(PlayerSleepInBedEvent event) {
    SettingEntry se = null;
    if (event.entityPlayer.worldObj.isRemote) {
      se = PerfectSpawnClientHandler.currentServerSettings;
    } else {
      se = PerfectSpawn.settings.getValidSettingEntry();
    }

    if (se != null && se.forceBed) {
      WorldProvider provider = event.entityPlayer.worldObj.provider;
      EntityPlayer player = event.entityPlayer;
      World worldObj = player.worldObj;

      if (provider.dimensionId == se.spawnDimension) {
        event.result = EntityPlayer.EnumStatus.OK;
        if (player.isPlayerSleeping() || !player.isEntityAlive()) {
          event.result = EntityPlayer.EnumStatus.OTHER_PROBLEM;
        }

        if (!player.worldObj.isDaytime() && provider.isSurfaceWorld()) {
          event.result = EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW;
        }

        if (Math.abs(player.posX - (double) event.x) > 3.0D
            || Math.abs(player.posY - (double) event.y) > 2.0D
            || Math.abs(player.posZ - (double) event.z) > 3.0D) {
          event.result = EntityPlayer.EnumStatus.TOO_FAR_AWAY;
        }

        double d0 = 8.0D;
        double d1 = 5.0D;
        List list =
            player.worldObj.getEntitiesWithinAABB(
                EntityMob.class,
                AxisAlignedBB.getBoundingBox(
                    (double) event.x - d0,
                    (double) event.y - d1,
                    (double) event.z - d0,
                    (double) event.x + d0,
                    (double) event.y + d1,
                    (double) event.z + d0));

        if (!list.isEmpty()) {
          event.result = EntityPlayer.EnumStatus.NOT_SAFE;
        }
      }

      if (player.isRiding()) {
        player.mountEntity((Entity) null);
      }

      this.setSize(player, 0.2F, 0.2F);
      player.yOffset = 0.2F;

      if (player.worldObj.blockExists(event.x, event.y, event.z)) {
        int l =
            worldObj
                .getBlock(event.x, event.y, event.z)
                .getBedDirection(worldObj, event.x, event.y, event.z);
        float f1 = 0.5F;
        float f = 0.5F;

        switch (l) {
          case 0:
            f = 0.9F;
            break;
          case 1:
            f1 = 0.1F;
            break;
          case 2:
            f = 0.1F;
            break;
          case 3:
            f1 = 0.9F;
        }

        this.func_71013_b(player, l);
        player.setPosition(
            (double) ((float) event.x + f1),
            (double) ((float) event.y + 0.9375F),
            (double) ((float) event.z + f));
      } else {
        player.setPosition(
            (double) ((float) event.x + 0.5F),
            (double) ((float) event.y + 0.9375F),
            (double) ((float) event.z + 0.5F));
      }

      try {
        sleepTimer.set(player, 0);
        sleeping.set(player, true);
      } catch (Exception e) {
        PerfectSpawn.instance.logger.log(Level.ERROR, "Couldn't reflect on player bed data");
        e.printStackTrace();
      }

      player.playerLocation = new ChunkCoordinates(event.x, event.y, event.z);
      player.motionX = player.motionZ = player.motionY = 0.0D;

      if (!player.worldObj.isRemote) {
        player.worldObj.updateAllPlayersSleepingFlag();
      }
    }
  }