Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 public void addInformation(ItemStack stack, EntityPlayer player, List lore, boolean idk) {
   ItemUtils.checkCompound(stack);
   if (getFocus(stack) != null) {
     String[] array = getFocus(stack).getLore(stack);
     for (String s : array) lore.add(LocalizationUtils.translateLocalWithColours(s, s));
   }
 }
  @SubscribeEvent
  public void entityHurt(LivingHurtEvent event) {
    if (event.entityLiving instanceof EntityPlayer
        && event.source == DamageSource.outOfWorld
        && ((EntityPlayer) event.entityLiving).posY < 0
        && isServer()) {
      EntityPlayer player = (EntityPlayer) event.entityLiving;
      if (!DiscoveryManager.itemUnlocked(QADiscoveries.Item.VACUUM.get().getKey(), player)
          && DiscoveryManager.areParentsUnlocked(
              QADiscoveries.Item.VACUUM.get().getKey(), player)) {
        String translate = "qa.aboutToVoid";
        player.addChatComponentMessage(
            new ChatComponentText(
                LocalizationUtils.translateLocalWithColours(translate, translate)));
        ChunkCoordinates spawn = player.getBedLocation(player.worldObj.provider.dimensionId);

        ChunkCoordinates portalEntrance =
            MinecraftServer.getServer()
                .worldServerForDimension(player.dimension)
                .getEntrancePortalLocation();
        if (portalEntrance != null && spawn == null) {
          spawn = portalEntrance;
        }

        if (spawn == null) {
          spawn = player.worldObj.getSpawnPoint();
        }

        int y = spawn.posY;

        while (!player.worldObj.isAirBlock(spawn.posX, y, spawn.posZ)) // Get top block
        y++;

        player.setPositionAndUpdate(spawn.posX, y, spawn.posZ);
        player.fallDistance = 0F;

        DiscoveryManager.unlockItem(QADiscoveries.Item.VACUUM.get().getKey(), player, false);
      }
    }
  }