示例#1
0
 public void a(EntityPlayer entityplayer, boolean flag0) {
   super.a(entityplayer, flag0);
   this.cp = -1;
   this.cm = -1;
   this.cn = -1;
   this.g.addAll(((EntityPlayerMP) entityplayer).g);
 }
示例#2
0
 public void a(NBTTagCompound nbttagcompound) {
   super.a(nbttagcompound);
   if (nbttagcompound.b("playerGameType")) {
     // XXX Check this, it was only the last call to this.c.a
     if (MinecraftServer.D().am()) {
       this.c.a(MinecraftServer.D().g());
     } else {
       this.c.a(EnumGameType.a(nbttagcompound.e("playerGameType")));
     }
   }
 }
示例#3
0
  @Override
  public boolean teleport(Location location) {
    WorldServer oldWorld = ((CraftWorld) getWorld()).getHandle();
    WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    ServerConfigurationManager manager = server.getHandle();
    EntityPlayer entity = getHandle();
    boolean teleportSuccess;

    if (oldWorld != newWorld) {

      EntityPlayer newEntity =
          new EntityPlayer(manager.c, newWorld, entity.name, new ItemInWorldManager(newWorld));

      newEntity.id = entity.id;
      newEntity.a = entity.a;
      newEntity.health = entity.health;
      newEntity.fireTicks = entity.fireTicks;
      newEntity.inventory = entity.inventory;
      newEntity.inventory.d = newEntity;
      newEntity.activeContainer = entity.activeContainer;
      newEntity.defaultContainer = entity.defaultContainer;
      newEntity.lastwarp = entity.lastwarp; // Buck - It
      newEntity.locX = location.getX();
      newEntity.locY = location.getY();
      newEntity.locZ = location.getZ();
      newEntity.displayName = entity.displayName;
      newEntity.compassTarget = entity.compassTarget;
      newEntity.fauxSleeping = entity.fauxSleeping;
      newWorld.u.c((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4);

      teleportSuccess = newEntity.a.teleport(location);

      if (teleportSuccess) {
        manager.c.k.a(entity);
        manager.c.k.b(entity);
        oldWorld.manager.b(entity);
        manager.b.remove(entity);
        oldWorld.e(entity);

        newWorld.manager.a(newEntity);
        newWorld.a(newEntity);
        manager.b.add(newEntity);

        entity.a.e = newEntity;
        this.entity = newEntity;

        setCompassTarget(getCompassTarget());
      }

      return teleportSuccess;
    } else {
      return entity.a.teleport(location);
    }
  }
示例#4
0
 public void a(Entity entity) {
   super.a(entity);
   this.a.b(new Packet39AttachEntity(this, this.o));
   this.a.a(
       this.u,
       this.v,
       this.w,
       this.A,
       this.B,
       getCanaryWorld().getType().getId(),
       getCanaryWorld().getName());
 }
  protected void a(WorldSettings.EnumGamemode worldsettings_enumgamemode) {
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    minecraftserver.setGamemode(worldsettings_enumgamemode);
    EntityPlayer entityplayer;

    if (minecraftserver.getForceGamemode()) {
      for (Iterator iterator = MinecraftServer.getServer().getPlayerList().v().iterator();
          iterator.hasNext();
          entityplayer.fallDistance = 0.0F) {
        entityplayer = (EntityPlayer) iterator.next();
        entityplayer.a(worldsettings_enumgamemode);
      }
    }
  }
示例#6
0
  public void a(boolean flag0, boolean flag1, boolean flag2) {
    if (this.bz()) {
      this.o().q().b(this, new Packet18Animation(this, 3));
    }

    super.a(flag0, flag1, flag2);
    if (this.a != null) {
      this.a.a(
          this.u,
          this.v,
          this.w,
          this.A,
          this.B,
          getCanaryWorld().getType().getId(),
          getCanaryWorld().getName());
    }
  }
示例#7
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY)
      return;

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest) {
      boolean silentchest = false;
      boolean anychest = false;
      int x = event.getClickedBlock().getX();
      int y = event.getClickedBlock().getY();
      int z = event.getClickedBlock().getZ();

      if (PermissionRelay.hasPermission(event.getPlayer(), "silent")
          && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName())) {
        silentchest = true;
      }

      if (PermissionRelay.hasPermission(event.getPlayer(), "anychest")
          && OpenInv.GetPlayerAnyChestStatus(event.getPlayer().getName())) {
        try {
          // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
          EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
          World world = player.world;
          // If block on top
          if (world.e(x, y + 1, z)) anychest = true;

          // If block next to chest is chest and has a block on top
          if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
            anychest = true;
          if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
            anychest = true;
          if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
            anychest = true;
          if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
            anychest = true;
        } catch (Exception e) {
          event
              .getPlayer()
              .sendMessage(
                  ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
          e.printStackTrace();
        }
      }

      // If the anychest or silentchest is active
      if (anychest || silentchest) {
        EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
        World world = player.world;
        Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
        if (chest == null) return;

        if (!anychest) {
          if (world.e(x, y + 1, z)) return;
          if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
            return;
          if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
            return;
          if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
            return;
          if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
            return;
        }

        if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (TileEntityChest) world.getTileEntity(x - 1, y, z),
                  (IInventory) chest);
        if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (IInventory) chest,
                  (TileEntityChest) world.getTileEntity(x + 1, y, z));
        if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (TileEntityChest) world.getTileEntity(x, y, z - 1),
                  (IInventory) chest);
        if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (IInventory) chest,
                  (TileEntityChest) world.getTileEntity(x, y, z + 1));

        if (!silentchest) {
          player.a((IInventory) chest);
        } else {
          try {
            Field windowID;
            try {
              windowID = player.getClass().getDeclaredField("cl");
            } catch (NoSuchFieldException e) {
              windowID = player.getClass().getDeclaredField("ci");
            }
            windowID.setAccessible(true);
            int id = windowID.getInt(player);
            id = id % 100 + 1;
            windowID.setInt(player, id);
            player.netServerHandler.sendPacket(
                new Packet100OpenWindow(
                    id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
            player.activeContainer =
                new SilentContainerChest(player.inventory, ((IInventory) chest));
            player.activeContainer.windowId = id;
            player.activeContainer.a((ICrafting) player);
            event.getPlayer().sendMessage("You are opening a chest silently.");
            event.setUseInteractedBlock(Result.DENY);
            event.setCancelled(true);
          } catch (Exception e) {
            e.printStackTrace();
            event.getPlayer().sendMessage(ChatColor.RED + "Error while sending silent chest.");
          }
        }

        if (anychest) event.getPlayer().sendMessage("You are opening a blocked chest.");
      }
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Sign) {
      Player player = event.getPlayer();
      try {
        Sign sign = ((Sign) event.getClickedBlock().getState());
        if (PermissionRelay.hasPermission(player, "openinv")
            && sign.getLine(0).equalsIgnoreCase("[openinv]")) {
          String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
          player.performCommand("openinv " + text);
        }
      } catch (Exception ex) {
        player.sendMessage("Internal Error.");
        ex.printStackTrace();
      }
    }

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      Player player = event.getPlayer();

      if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem())
          || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
          || !PermissionRelay.hasPermission(player, "openinv")) {
        return;
      }

      player.performCommand("openinv");
    }
  }
示例#8
0
 protected void a(PotionEffect potioneffect) {
   super.a(potioneffect);
   this.a.b(new Packet41EntityEffect(this.k, potioneffect));
 }
示例#9
0
 public void a(ItemStack itemstack, int i0) {
   super.a(itemstack, i0);
   if (itemstack != null && itemstack.b() != null && itemstack.b().b_(itemstack) == EnumAction.b) {
     this.o().q().b(this, new Packet18Animation(this, 5));
   }
 }
示例#10
0
 public void b(double d0, boolean flag0) {
   super.a(d0, flag0);
 }
示例#11
0
 public void a(Entity entity, int i0) {
   super.a(entity, i0);
   this.bM.b();
 }
示例#12
0
 public void a(int i0) {
   super.a(i0);
   this.cp = -1;
 }
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.useInteractedBlock() == Result.DENY || event.isCancelled()) return;

    boolean silentchest = false;
    boolean anychest = false;
    int x = event.getClickedBlock().getX();
    int y = event.getClickedBlock().getY();
    int z = event.getClickedBlock().getZ();

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest
        && PermissionRelay.hasPermission(event.getPlayer(), "OpenInv.silent")
        && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName())) {
      silentchest = true;
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest
        && PermissionRelay.hasPermission(event.getPlayer(), "OpenInv.anychest")) {
      try {
        EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
        World world = player.world;
        // If block on top
        if (world.e(x, y + 1, z)) anychest = true;

        // If block next to chest is chest and has a block on top
        if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
          anychest = true;
        if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
          anychest = true;
        if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
          anychest = true;
        if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
          anychest = true;
      } catch (Exception e) // Incompatible CraftBukkit?
      {
        e.printStackTrace();
        event
            .getPlayer()
            .sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
      }
    }

    // If the chest is blocked
    if (anychest || silentchest) {
      EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
      World world = player.world;
      Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
      if (chest == null) return;

      if (!anychest) {
        if (world.e(x, y + 1, z)) return;
        if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z))) return;
        if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z))) return;
        if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1))) return;
        if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1))) return;
      }

      if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (TileEntityChest) world.getTileEntity(x - 1, y, z),
                (IInventory) chest);
      if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (IInventory) chest,
                (TileEntityChest) world.getTileEntity(x + 1, y, z));
      if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (TileEntityChest) world.getTileEntity(x, y, z - 1),
                (IInventory) chest);
      if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (IInventory) chest,
                (TileEntityChest) world.getTileEntity(x, y, z + 1));

      if (!silentchest) {
        player.a((IInventory) chest);
      } else {
        try {
          Field ciField = player.getClass().getDeclaredField("ci");
          ciField.setAccessible(true);
          int ci = ciField.getInt(player);
          ci = ci % 100 + 1;
          ciField.setInt(player, ci);
          player.netServerHandler.sendPacket(
              new Packet100OpenWindow(
                  ci, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
          player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
          System.out.println(player.activeContainer.toString());
          player.activeContainer.windowId = ci;
          player.activeContainer.a((ICrafting) player);
          event.getPlayer().sendMessage("You are opening a silent chest.");
        } catch (Exception e) {
          e.printStackTrace();
          event.getPlayer().sendMessage(ChatColor.RED + "Error while sending silent chest.");
        }
      }

      if (anychest) event.getPlayer().sendMessage("You are opening a blocked chest.");
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && (event.getClickedBlock() == Block.CHEST
            || event.getClickedBlock() == Block.FURNACE
            || event.getClickedBlock() == Block.DISPENSER)) {
      return;
    }

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      Player player = event.getPlayer();

      if (!(player.getItemInHand().getType() == Material.STICK)
          || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
          || !PermissionRelay.hasPermission(player, "openinv")) {
        return;
      }

      player.performCommand("openinv");
    }

    if (event.getAction() == Action.LEFT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Sign) {
      Player player = event.getPlayer();
      try {
        if (PermissionRelay.hasPermission(player, "openinv")
            && ((Sign) event.getClickedBlock().getState())
                .getLine(0)
                .equalsIgnoreCase("[openinv]")) {
          if (plugin.getServer().getPlayer(((Sign) event.getClickedBlock().getState()).getLine(1))
              != null) {
            Sign sign = ((Sign) event.getClickedBlock().getState());
            String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(2).trim();
            player.performCommand("openinv " + text);
          } else {
            player.sendMessage("Player not found.");
          }
        }
      } catch (Exception ex) {
        player.sendMessage("Internal Error.");
        ex.printStackTrace();
      }
    }
  }
示例#14
0
 @Override
 public void a(EntityLiving entityliving) {
   System.out.println(entityliving);
   super.a(entityliving);
 }
示例#15
0
  public void a(EntityPlayer entityplayer) {
    int i0 = entityplayer.q.r;

    this.e = this.a;
    if (this.c > 4.0F) {
      // CanaryMod: FoodExhaustionHook
      FoodExhaustionHook exh =
          new FoodExhaustionHook(
              ((EntityPlayerMP) entityplayer).getPlayer(), this.c, this.c - 4.0F);

      Canary.hooks().callHook(exh);
      this.c = exh.getNewValue();
      //
      if (this.b > 0.0F) {
        // CanaryMod: FoodSaturationHook
        FoodSaturationHook sat =
            new FoodSaturationHook(
                ((EntityPlayerMP) entityplayer).getPlayer(), this.b, Math.max(this.b - 1.0F, 0.0F));

        Canary.hooks().callHook(sat);
        this.b = Math.max(Math.min(sat.getNewValue(), (float) this.a), 0.0F);
        //
      } else if (i0 > 0) {
        // CanaryMod: FoodLevelHook
        FoodLevelHook lvl =
            new FoodLevelHook(
                ((EntityPlayerMP) entityplayer).getPlayer(), this.a, Math.max(this.a - 1, 0));

        Canary.hooks().callHook(lvl);
        this.a = Math.max(Math.min(lvl.getNewValue(), 20), 0);
        //
      }
    }

    if (this.a >= 18 && entityplayer.cm()) {
      ++this.d;
      if (this.d >= 80) {
        entityplayer.j(1);
        this.d = 0;
      }
    } else if (this.a <= 0) {
      ++this.d;
      if (this.d >= 80) {
        if (entityplayer.aX() > 10 || i0 >= 3 || entityplayer.aX() > 1 && i0 >= 2) {
          // CanaryMod: DamageHook (starve)
          DamageHook dmg =
              new DamageHook(
                  null, entityplayer.getCanaryEntity(), new CanaryDamageSource(DamageSource.f), 1);

          Canary.hooks().callHook(dmg);
          if (!dmg.isCanceled()) {
            entityplayer.a(
                (((CanaryDamageSource) dmg.getDamageSource()).getHandle()), dmg.getDamageDealt());
          }
          //
        }

        this.d = 0;
      }
    } else {
      this.d = 0;
    }
  }