@Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int p_149727_6_,
     float p_149727_7_,
     float p_149727_8_,
     float p_149727_9_) {
   AbstractInvExpander expander = (AbstractInvExpander) world.getTileEntity(x, y, z);
   TurretBase base = expander.getBase();
   if (base != null && base.getTrustedPlayer(player.getUniqueID()) != null) {
     if (base.getTrustedPlayer(player.getUniqueID()).canOpenGUI) {
       player.openGui(ModularTurrets.instance, 7, world, x, y, z);
       return true;
     }
   }
   if (base != null && player.getUniqueID().toString().equals(base.getOwner())) {
     player.openGui(ModularTurrets.instance, 7, world, x, y, z);
   } else {
     player.addChatMessage(
         new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
   }
   return true;
 }
Esempio n. 2
0
 @SubscribeEvent
 public void onPlayerTick(TickEvent.PlayerTickEvent event) {
   if (event.player == player) {
     for (EntityPlayer player1 : player.worldObj.playerEntities) {
       boolean pokemob;
       PokeInfo info = proxy.getMap().get(player.getUniqueID());
       if (info == null) {
         proxy.getPokemob(player);
         info = proxy.getMap().get(player.getUniqueID());
         pokemob = info != null;
         pokemob = pokemob && player.getEntityData().getBoolean("isPokemob");
       } else {
         pokemob = player.getEntityData().getBoolean("isPokemob");
       }
       PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(6));
       MessageClient message = new MessageClient(buffer);
       buffer.writeByte(MessageClient.SETPOKE);
       buffer.writeInt(player1.getEntityId());
       buffer.writeBoolean(pokemob);
       if (pokemob) {
         buffer.writeFloat(info.originalHeight);
         buffer.writeFloat(info.originalWidth);
         buffer.writeNBTTagCompoundToBuffer(player1.getEntityData().getCompoundTag("Pokemob"));
       }
       PokecubeMod.packetPipeline.sendTo(message, (EntityPlayerMP) player);
       MinecraftForge.EVENT_BUS.unregister(this);
     }
   }
 }
  public void startCooking(EntityPlayer player) {
    assigningPlayer = player.getUniqueID().toString();

    setIsActive(true);
    furnacePos = Point3D.ZERO;
    cookingInterval = Time.SECOND * 8;
  }
  @Override
  public boolean interact(EntityPlayer par1EntityPlayer) {
    ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();

    if (this.isTamed()) {
      if (var2 != null) {
        if (var2.getItem() instanceof ItemFood) {
          ItemFood var3 = (ItemFood) var2.getItem();

          if (var3.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < 60) {
            if (!par1EntityPlayer.capabilities.isCreativeMode) {
              --var2.stackSize;
            }

            this.heal(var3.func_150905_g(var2));

            if (var2.stackSize <= 0) {
              par1EntityPlayer.inventory.setInventorySlotContents(
                  par1EntityPlayer.inventory.currentItem, (ItemStack) null);
            }

            return true;
          }
        }
      }
    } else {
      this.setTamed(true);
      this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
    }

    return super.interact(par1EntityPlayer);
  }
  public StatisticsFile getPlayerStatsFile(EntityPlayer playerIn) {
    UUID var2 = playerIn.getUniqueID();
    StatisticsFile var3 = var2 == null ? null : (StatisticsFile) this.playerStatFiles.get(var2);

    if (var3 == null) {
      File var4 =
          new File(
              this.mcServer.worldServerForDimension(0).getSaveHandler().getWorldDirectory(),
              "stats");
      File var5 = new File(var4, var2.toString() + ".json");

      if (!var5.exists()) {
        File var6 = new File(var4, playerIn.getName() + ".json");

        if (var6.exists() && var6.isFile()) {
          var6.renameTo(var5);
        }
      }

      var3 = new StatisticsFile(this.mcServer, var5);
      var3.func_150882_a();
      this.playerStatFiles.put(var2, var3);
    }

    return var3;
  }
Esempio n. 6
0
  @SuppressWarnings({"unchecked", "ConstantConditions"})
  @Command(
      aliases = "pm",
      desc = "Send private message to target player.",
      usage = "/pm <target player> <message>")
  public void sendPm(@Sender EntityPlayer sender, String target, @Text String message) {

    try {
      UserId userId = profileService.findUserId(target);
      if (!Objects.equals(sender.getDisplayName(), userId.getEntityPlayer().getDisplayName())) {
        userId
            .getEntityPlayer()
            .addChatMessage(
                new ChatComponentText(
                    String.format(
                        "%s(%s - Message from %s%s: %s)",
                        EnumChatFormatting.GRAY,
                        formattedDate,
                        sender.getDisplayName(),
                        EnumChatFormatting.GRAY,
                        message.trim())));
        recipients.put(sender.getUniqueID(), profileService.findUserId(target));
      }
      if (Objects.equals(sender.getDisplayName(), userId.getEntityPlayer().getDisplayName())) {
        sender.addChatMessage(Messages.error(tr("whisper.pm.same-player.error")));
      }
    } catch (ProfileNotFoundException | NullPointerException e) {
      sender.addChatMessage(Messages.error(tr("whisper.pm.no-such-player.error")));
    } catch (ProfileLookupException ignored) {
    }
  }
  public void startKilling(EntityPlayer player) {
    assigningPlayer = player.getUniqueID().toString();

    standPoint = Point3D.ZERO;
    isTaming = false;

    setIsActive(true);
    owner.setMovementState(EnumMovementState.MOVE);
  }
 @Override
 public void onCreated(ItemStack stack, World world, EntityPlayer player) {
   if (player.getCommandSenderName() != null) {
     if ((stack.getItem() == InitItems.itemHammer)
         && Arrays.asList(LibInfo.names).contains(player.getUniqueID().toString())) {
       stack.stackSize = 0;
       stack.func_150996_a(InitItems.itemBugHammer);
     }
   }
 }
Esempio n. 9
0
  @SideOnly(Side.CLIENT)
  public static void set2Handing(boolean value) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;

    if (is2Handing() != value) {
      OglMod.net.sendToServer(
          new ActionMessage(
              player.getUniqueID(),
              value ? ActionMessage.Action.START_2HANDING : ActionMessage.Action.STOP_2HANDING));
    }
  }
 @Override
 public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
   TileEntityDoorController tileEntity = (TileEntityDoorController) world.getTileEntity(x, y, z);
   // If the user is not the owner, or the user is not in creative drop out.
   if (tileEntity.getOwner() != null) {
     if (tileEntity.getOwner().equals(player.getUniqueID().toString())) {
       this.setResistance(0F);
       this.setHardness(0F);
     }
   }
 }
  @Override
  public void onBlockPlacedBy(
      World world, int par2, int par3, int par4, EntityLivingBase living, ItemStack stack) {
    int l = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    int meta = stack.getItemDamage();
    byte facing = 0;

    if (l == 0) {
      world.setBlockMetadataWithNotify(par2, par3, par4, 0, 3);
      facing = 0;
    }

    if (l == 1) {
      world.setBlockMetadataWithNotify(par2, par3, par4, 1, 3);
      facing = 1;
    }

    if (l == 2) {
      world.setBlockMetadataWithNotify(par2, par3, par4, 2, 3);
      facing = 2;
    }

    if (l == 3) {
      world.setBlockMetadataWithNotify(par2, par3, par4, 3, 3);
      facing = 3;
    }

    TileEntity tile = world.getTileEntity(par2, par3, par4);
    OrderExchanger tileentity = null;
    if (tile != null && tile instanceof OrderExchanger) {
      tileentity = (OrderExchanger) tile;
    }

    if (tileentity != null) {
      NBTTagCompound tag = stack.getTagCompound();
      if (tag != null) {
        tileentity.setNBT(tag);
      }

      if (!world.isRemote
          && living instanceof EntityPlayer
          && tileentity.getOwnerName().equalsIgnoreCase("none")) {
        EntityPlayer player = (EntityPlayer) living;
        String name = player.getCommandSenderName();
        String uuid = player.getUniqueID().toString();
        tileentity.setOwnerName(name);
        tileentity.setOwnerUUID(uuid);
      }
    }
  }
Esempio n. 12
0
  @Override
  public File getPlayerSchematicDirectory(EntityPlayer player, boolean privateDirectory) {
    final UUID playerId = player.getUniqueID();
    if (playerId == null) {
      Reference.logger.warn("Unable to identify player {}", player.toString());
      return null;
    }

    File playerDir =
        new File(ConfigurationHandler.schematicDirectory.getAbsolutePath(), playerId.toString());
    if (privateDirectory) {
      return new File(playerDir, "private");
    } else {
      return new File(playerDir, "public");
    }
  }
Esempio n. 13
0
 @Override
 public boolean onSkillTrigger(EntityPlayer player) {
   if (!canPlayerUseSkill(player)) return false;
   player.inventory.consumeInventoryItem(Items.bone);
   player.worldObj.playSoundAtEntity(player, "mob.ghast.fireball", 1.0F, 1.0F);
   EntityWolf wolf = new EntityWolf(player.worldObj);
   wolf.setLocationAndAngles(
       player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
   wolf.spawnExplosionParticle();
   if (!player.worldObj.isRemote) {
     wolf.setTamed(true);
     wolf.getNavigator().clearPathEntity();
     wolf.setAttackTarget(null);
     wolf.setSitting(false);
     wolf.setHealth(20);
     wolf.setOwnerId(player.getUniqueID().toString());
     player.worldObj.setEntityState(wolf, (byte) 7);
     player.worldObj.spawnEntityInWorld(wolf);
   }
   return true;
 }
Esempio n. 14
0
  @Override
  public boolean interact(EntityPlayer entityPlayer) {
    // Only the owner can interact with extended spiders.
    if (owner.equals(entityPlayer.getUniqueID())) {
      // Pack spider displays its inventory.
      if (spiderType == EnumSpiderType.PACK) {
        entityPlayer.displayGUIChest(inventory);
      }

      // Rider spider causes the player to mount it.
      else if (spiderType == EnumSpiderType.RIDER) {
        entityPlayer.rotationYaw = rotationYaw;
        entityPlayer.rotationPitch = rotationPitch;

        if (!worldObj.isRemote) {
          entityPlayer.mountEntity(this);
        }
      }
    }

    return true;
  }
Esempio n. 15
0
 @Command(
     aliases = "r",
     desc = "Reply to the person, that sent you the last message.",
     usage = "/r <message>")
 public void replyToPm(@Sender EntityPlayer sender, @Text String message) {
   try {
     UserId target = (UserId) recipients.get(sender.getUniqueID());
     if (target.getEntityPlayer() != null) {
       target
           .getEntityPlayer()
           .addChatMessage(
               new ChatComponentText(
                   String.format(
                       "%s(%s - Message from %s%s: %s)",
                       EnumChatFormatting.GRAY,
                       formattedDate,
                       sender.getDisplayName(),
                       EnumChatFormatting.GRAY,
                       message.trim())));
     }
   } catch (NullPointerException e) {
     sender.addChatMessage(Messages.error(tr("whisper.r.nobody-to-reply-to")));
   }
 }
 public boolean setTamedBy(EntityPlayer p_110263_1_) {
   this.func_152120_b(p_110263_1_.getUniqueID().toString());
   this.setHorseTamed(true);
   return true;
 }
Esempio n. 17
0
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    ArrowNockEvent event = new ArrowNockEvent(player, stack);
    {
      player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
    }

    if (!stack.hasTagCompound()) {
      stack.stackTagCompound = new NBTTagCompound();
      stack.stackTagCompound.setBoolean("valid", false);
      stack.stackTagCompound.setBoolean("superuser", false);
    }

    if (!player.isSneaking()) {
      if (stack.stackTagCompound.getBoolean("valid")) {
        if ((player.inventory.hasItem(ModItems.nugget_euphemium)
            || player.inventory.hasItem(ModItems.ingot_euphemium))) {
        } else {
          if (!player.inventory.hasItem(ModItems.nugget_euphemium)
              && !player.inventory.hasItem(ModItems.ingot_euphemium)) {
            stack.stackTagCompound.setBoolean("valid", false);
            if (world.isRemote) {
              player.addChatMessage(new ChatComponentText("[ZOMG] Validation lost!"));
              player.addChatMessage(new ChatComponentText("[ZOMG] Request new validation!"));
            }
          }
        }
      } else {
        if (world.isRemote) {
          player.addChatMessage(new ChatComponentText("[ZOMG] Gun not validated!"));
          player.addChatMessage(
              new ChatComponentText("[ZOMG] Validate your gun with shift right-click."));
        }
      }
    } else {
      if (stack.stackTagCompound.getBoolean("valid")) {
        if (world.isRemote) {
          player.addChatMessage(new ChatComponentText("[ZOMG] Gun has already been validated."));
        }
      } else {
        if (player.inventory.hasItem(ModItems.nugget_euphemium)
            || player.inventory.hasItem(ModItems.ingot_euphemium)) {
          stack.stackTagCompound.setBoolean("valid", true);
          if (world.isRemote) {
            player.addChatMessage(new ChatComponentText("[ZOMG] Gun has been validated!"));
          }

          if (Library.superuser.contains(player.getUniqueID().toString())) {
            if (world.isRemote) {
              player.addChatMessage(new ChatComponentText("[ZOMG] Welcome, superuser!"));
            }
            stack.stackTagCompound.setBoolean("superuser", true);
          } else {
            if (world.isRemote) {
              player.addChatMessage(new ChatComponentText("[ZOMG] Welcome, user!"));
            }
            stack.stackTagCompound.setBoolean("superuser", false);
          }
        } else {
          if (world.isRemote) {
            player.addChatMessage(new ChatComponentText("[ZOMG] Validation failed!"));
            player.addChatMessage(
                new ChatComponentText("[ZOMG] No external negative gravity well found!"));
          }
        }
      }
    }

    return stack;
  }
  @SuppressWarnings("rawtypes")
  @SubscribeEvent
  public void onPlayerUpdate(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    if (Utilities.isServerSide()) {
      if (player.isPotionActive(ZombieInfection.potionInfection)
          && !player.isPotionActive(ZombieInfection.potionCure)) {
        int timeInfected = TimeInfectedTracking.getSecondsInfected(player);
        for (CustomInfectionEffect customEffect : ZombieInfectionAPI.getCustomInfectionEffects()) {
          customEffect.run(player, timeInfected);
        }

        player.addPotionEffect(PotionHelper.createInfection(timeInfected < 60 ? 0 : 1));
        if (ConfigurationHandler.enableSlowness())
          player.addPotionEffect(PotionHelper.createSlowness(timeInfected < 60 ? 0 : 1));
        if (ConfigurationHandler.enableHunger() && timeInfected >= 20)
          player.addPotionEffect(PotionHelper.createHunger(timeInfected < 80 ? 0 : 1));
        if (ConfigurationHandler.enableMiningFatigue() && timeInfected >= 40)
          player.addPotionEffect(PotionHelper.createMiningFatigue(timeInfected < 100 ? 0 : 1));
        if (ConfigurationHandler.enableWeakness() && timeInfected >= 60)
          player.addPotionEffect(PotionHelper.createWeakness(timeInfected < 120 ? 0 : 1));
        if (ConfigurationHandler.enableWither() && timeInfected >= 480)
          player.addPotionEffect(PotionHelper.createWither(0));

        if (player.getFoodStats().getFoodLevel() > FoodTracking.get(player)) {
          player
              .getFoodStats()
              .addStats(FoodTracking.get(player) - player.getFoodStats().getFoodLevel(), 0);
          EntityPlayerMP playerMP =
              FMLCommonHandler.instance()
                  .getMinecraftServerInstance()
                  .getConfigurationManager()
                  .getPlayerByUsername(player.getCommandSenderName());
          PacketHandler.INSTANCE.sendTo(
              PacketHandler.getFoodChangePacket(
                  player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()),
              playerMP);
        }

        FoodTracking.put(player);

        int curSecond = Calendar.getInstance().get(Calendar.SECOND);
        if (curSecond != lastSecond) {
          lastSecond = curSecond;
          TimeInfectedTracking.update(player);
        }

        if (player.worldObj.canBlockSeeTheSky(
                (int) player.posX, (int) player.posY, (int) player.posZ)
            && player.worldObj.isDaytime()
            && !player.worldObj.isRaining()
            && !player.worldObj.isThundering()
            && timeInfected >= 80
            && player.inventory.armorInventory[3] == null) {
          player.setFire(1);
        }

        if (!FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()
            && ConfigurationHandler.getSpreadEnabled()) {
          Iterator players =
              FMLCommonHandler.instance()
                  .getMinecraftServerInstance()
                  .getConfigurationManager()
                  .playerEntityList
                  .iterator();

          while (players.hasNext()) {
            Object thing = players.next();
            if (thing instanceof EntityPlayer) {
              EntityPlayer anotherPlayer = (EntityPlayer) thing;
              if (anotherPlayer.getDistanceToEntity(player)
                  < ConfigurationHandler.getSpreadDistance()) {
                if (anotherPlayer.getUniqueID() != player.getUniqueID()) {
                  if (!anotherPlayer.isPotionActive(ZombieInfection.potionInfection)) {
                    anotherPlayer.addChatMessage(
                        new ChatComponentTranslation("zombieinfection.chat.playerinfected"));
                    anotherPlayer.addPotionEffect(PotionHelper.createInfection(0));
                  }
                }
              }
            }
          }
        }
      } else {
        TimeInfectedTracking.remove(player);
        FoodTracking.remove(player);
      }
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float clickX,
      float clickY,
      float clickZ) {
    TileEntityDoorController tileEntity = (TileEntityDoorController) world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
      return false;
    }

    // If the user is not the owner, or the user is not in creative drop out.
    if (tileEntity.getOwner() != null) {
      if (!tileEntity.getOwner().equals(player.getUniqueID().toString())
          && !player.capabilities.isCreativeMode) {
        if (!tileEntity.getOwner().isEmpty()) {
          return false;
        }
      }
    }
    // Change the block texture
    if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof ItemBlock) {
      Block block = Block.getBlockFromItem(player.getCurrentEquippedItem().getItem());
      Item oldBlock = tileEntity.DoorControllerCamo[0].getItem();
      if (block.isOpaqueCube()
          || block instanceof BlockGlass
          || block instanceof BlockStainedGlass) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(player.getCurrentEquippedItem().getItem())) {
          if (player.capabilities.isCreativeMode) {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(0),
                ForgeDirection.getOrientation(side));
          } else {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(1),
                ForgeDirection.getOrientation(side));
          }
          world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
          if (!world.isRemote) {
            ItemStack testAgainst = new ItemStack(oldBlock);
            if (!testAgainst
                .getItem()
                .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
              EntityItem myItemEntity = new EntityItem(world, x, y, z, testAgainst);
              world.spawnEntityInWorld(myItemEntity);
            }
          }
        }
      }
      // Remove the block texture with the scrench
    } else if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof Wrench) {
      if (!world.isRemote) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
          EntityItem myItemEntity =
              new EntityItem(world, x, y, z, tileEntity.DoorControllerCamo[0]);
          world.spawnEntityInWorld(myItemEntity);
        }
      }
      tileEntity.overrideTexture(
          ContentRegistry.DoorController,
          new ItemStack(Item.getItemFromBlock(ContentRegistry.DoorController)),
          ForgeDirection.getOrientation(side));
      world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
    }
    return true;
  }
  @Override
  protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id == 1) { // change Attack Mobs
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerMobs(!base.isAttacksMobs());
        guibutton.displayString =
            "Attack Mobs: " + (!base.isAttacksMobs() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerMobs(!base.isAttacksMobs());
        guibutton.displayString =
            "Attack Mobs: " + (!base.isAttacksMobs() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 2) { // change Attack Neutrals
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerNeutrals(!base.isAttacksNeutrals());
        guibutton.displayString =
            "Attack Neutrals: " + (!base.isAttacksNeutrals() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerNeutrals(!base.isAttacksNeutrals());
        guibutton.displayString =
            "Attack Neutrals: " + (!base.isAttacksNeutrals() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 3) { // change Attack Players
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerPlayers(!base.isAttacksPlayers());
        guibutton.displayString =
            "Attack Players: " + (!base.isAttacksPlayers() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerPlayers(!base.isAttacksPlayers());
        guibutton.displayString =
            "Attack Players: " + (!base.isAttacksPlayers() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 4) { // add trusted player
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        if (!textFieldAddTrustedPlayer.getText().equals("")
            || !textFieldAddTrustedPlayer.getText().isEmpty()) {
          base.addTrustedPlayer(textFieldAddTrustedPlayer.getText());
          sendChangeToServerAddTrusted();
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        }
      } else if (base.getTrustedPlayer(player.getUniqueID()).admin) {
        if (!textFieldAddTrustedPlayer.getText().equals("")
            || !textFieldAddTrustedPlayer.getText().isEmpty()) {
          base.addTrustedPlayer(textFieldAddTrustedPlayer.getText());
          sendChangeToServerAddTrusted();
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        }
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 5) { // remove trusted player
      if (base.getTrustedPlayers().size() > 0) {
        if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
            && player.getUniqueID().toString().equals(base.getOwner())) {
          sendChangeToServerRemoveTrusted();
          base.removeTrustedPlayer(base.getTrustedPlayers().get(base.trustedPlayerIndex).getName());
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        } else if (base.getTrustedPlayer(player.getUniqueID()).admin) {
          if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
              && this.base.getTrustedPlayers().size() > 0) {
            sendChangeToServerRemoveTrusted();
            base.removeTrustedPlayer(
                base.getTrustedPlayers().get(base.trustedPlayerIndex).getName());
            textFieldAddTrustedPlayer.setText("");
            this.base.trustedPlayerIndex = 0;
            if (this.base
                    .getTrustedPlayers()
                    .get(base.trustedPlayerIndex)
                    .uuid
                    .equals(player.getUniqueID())
                && !player.getUniqueID().toString().equals(base.getOwner())) {
              mc.displayGuiScreen(null);
              return;
            }
            player.openGui(
                ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
          }
        } else {
          player.addChatMessage(
              new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
        }
      }
    }

    if (guibutton.id == 6) { // decrease index of trusted player list
      if ((this.base.trustedPlayerIndex - 1 >= 0)) {
        this.base.trustedPlayerIndex--;
        player.openGui(
            ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
      }
    }

    if (guibutton.id == 7) { // increase index of trusted player list
      if (!((this.base.trustedPlayerIndex + 1) > (base.getTrustedPlayers().size() - 1))) {
        this.base.trustedPlayerIndex++;
        player.openGui(
            ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
      }
    }

    if (guibutton.id == 8) { // change trusted player permission for GUI opening
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "gui",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI
                ? "\u00A72Y"
                : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "gui",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI
                ? "\u00A72Y"
                : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 9) { // change trusted player permission for targeting
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "targeting",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting
                ? "\u00A72Y"
                : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "targeting",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting
                ? "\u00A72Y"
                : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 10) { // change trusted player permission for administering
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "isAdmin",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin ? "\u00A72Y" : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "isAdmin",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin ? "\u00A72Y" : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }
  }
Esempio n. 21
0
 public static UUID getUUID(EntityPlayer player) {
   return player.getUniqueID();
 }
 public final boolean canDrop(EntityPlayer ep) {
   return ep.getUniqueID().equals(placerUUID);
 }
Esempio n. 23
0
 @Override
 public boolean interact(EntityPlayer player) {
   ItemStack itemstack = player.inventory.getCurrentItem();
   if (!this.worldObj.isRemote) {
     // Allow taming in creative mode without items
     if (!this.isTamed() && player.capabilities.isCreativeMode) {
       this.func_152115_b(player.getUniqueID().toString()); // Set owner UUID
       this.setTamed(true);
     }
     // If tamed
     if (this.isTamed()) {
       // If player has item
       if (itemstack != null) {
         // If armour, equip it
         if (itemstack.getItem() instanceof ItemArmor && !player.isSneaking()) {
           int i = EntityLiving.getArmorPosition(itemstack) - 1;
           if (this.getEquipmentInSlot(i + 1) == null) {
             this.setCurrentItemOrArmor(i + 1, itemstack.copy());
             if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
               player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
           } else {
             EntityItem entityItem =
                 new EntityItem(
                     this.worldObj,
                     this.posX,
                     this.posY,
                     this.posZ,
                     this.getEquipmentInSlot(i + 1));
             this.worldObj.spawnEntityInWorld(entityItem);
             this.setCurrentItemOrArmor(i + 1, null);
           }
           return true;
         }
         // If lead and mounted, unmount
         else if (itemstack.getItem() == Items.lead && this.isRiding() && !player.isSneaking())
           this.mountEntity(null);
         // If entity is holding something and player is holding a stick, drop current item
         else if (itemstack.getItem() == Items.stick && this.getHeldItem() != null) {
           EntityItem entityItem =
               new EntityItem(
                   player.worldObj, this.posX, this.posY, this.posZ, this.getHeldItem().copy());
           player.worldObj.spawnEntityInWorld(entityItem);
           this.setCarrying(null);
           // Drop chest contents
           for (int i = 0; i < inventory.getSizeInventory(); i++) {
             ItemStack itemStackToDrop = inventory.getStackInSlot(i);
             if (itemStackToDrop != null) {
               entityItem =
                   new EntityItem(
                       player.worldObj, this.posX, this.posY, this.posZ, itemStackToDrop);
               player.worldObj.spawnEntityInWorld(entityItem);
             }
             inventory.setInventorySlotContents(i, null);
           }
         } else if (this.getHeldItem() == null) {
           ItemStack newItemStack = itemstack.copy();
           newItemStack.stackSize = 1;
           this.setCarrying(newItemStack);
           player.playSound(
               "mob.chickenplop",
               1.0F,
               (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
           if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
             player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
         }
       }
       // If entity is holding something and player isn't, open GUI
       if (this.getHeldItem() != null && !player.isSneaking()) {
         if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.chest)
           player.openGui(MiniCreatures.instance, 0, player.worldObj, this.getEntityId(), 0, 0);
         else if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.anvil)
           player.openGui(
               MiniCreatures.instance,
               1,
               player.worldObj,
               (int) this.posX,
               (int) this.posY,
               (int) this.posZ);
       } else if (player.isEntityEqual(this.getOwner()) && !this.worldObj.isRemote) {
         if (this.isRiding()) {
           EntityTameable ridingEntity = (EntityTameable) this.ridingEntity;
           ridingEntity.func_70907_r().setSitting(!ridingEntity.isSitting());
           ridingEntity.setSitting(!ridingEntity.isSitting());
           ridingEntity.setJumping(false);
           ridingEntity.setPathToEntity(null);
           ridingEntity.setTarget(null);
           ridingEntity.setAttackTarget(null);
         } else {
           this.aiSit.setSitting(!this.isSitting());
           this.setSitting(!this.isSitting());
           this.isJumping = false;
           this.setPathToEntity(null);
           this.setTarget(null);
           this.setAttackTarget(null);
         }
       }
     }
   }
   return super.interact(player);
 }
Esempio n. 24
0
 public EntityGolemOfRejuv(World par1World, EntityPlayer p) {
   this(par1World);
   this.func_152115_b(p.getUniqueID().toString());
   setTamed(true);
 }