Search in sources :

Example 26 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project CokesAddon by Cokes86.

the class v1_13_R1 method setPlayerNameTag.

@Override
public void setPlayerNameTag(Player p, UUID uuid) {
    if (origin.containsKey(uuid)) {
        try {
            EntityPlayer enp = ((CraftPlayer) p).getHandle();
            Object obj = enp.getClass().getMethod("getProfile", new Class[0]).invoke(enp);
            Field nameField = obj.getClass().getDeclaredField("name");
            nameField.setAccessible(true);
            nameField.set(obj, origin.get(uuid).getLeft());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Field(java.lang.reflect.Field) EntityPlayer(net.minecraft.server.v1_13_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer)

Example 27 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project CokesAddon by Cokes86.

the class v1_13_R2 method setPlayerNameTag.

@Override
public void setPlayerNameTag(Player p, UUID uuid) {
    if (origin.containsKey(uuid)) {
        try {
            EntityPlayer enp = ((CraftPlayer) p).getHandle();
            Object obj = enp.getClass().getMethod("getProfile", new Class[0]).invoke(enp);
            Field nameField = obj.getClass().getDeclaredField("name");
            nameField.setAccessible(true);
            nameField.set(obj, origin.get(uuid).getLeft());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Field(java.lang.reflect.Field) EntityPlayer(net.minecraft.server.v1_13_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)

Example 28 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project THP-Engine by TheHollowPlanetMC.

the class FlyPacketHandler method rewrite.

@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
    ParallelUniverse universe = EnginePlayer.getUniverse();
    if (universe == null)
        return packet;
    World world = EnginePlayer.getBukkitPlayer().getWorld();
    String worldName = world.getName();
    ParallelWorld parallelWorld = universe.getWorld(worldName);
    EntityPlayer entityPlayer = ((CraftPlayer) EnginePlayer.getBukkitPlayer()).getHandle();
    int x = NumberConversions.floor(entityPlayer.locX());
    int y = NumberConversions.floor(entityPlayer.locY());
    int z = NumberConversions.floor(entityPlayer.locZ());
    int downY = y - 1;
    downY = Math.max(0, downY);
    if (parallelWorld.hasBlockData(x, y, z) || parallelWorld.hasBlockData(x, downY, z)) {
        try {
            PlayerConnection playerConnection = entityPlayer.playerConnection;
            C.set(playerConnection, 0);
            E.set(playerConnection, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return packet;
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) World(org.bukkit.World) ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) PlayerConnection(net.minecraft.server.v1_15_R1.PlayerConnection)

Example 29 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    CraftingManager.getInstance().lastCraftView = getBukkitView();
    ItemStack craftResult = CraftingManager.getInstance().craft(craftInventory, world);
    resultInventory.setItem(0, craftResult);
    if (listeners.isEmpty()) {
        return;
    }
    if ((craftResult != null) && (craftResult.getItem() == Items.FILLED_MAP)) {
        return;
    }
    for (Object listener : listeners) {
        EntityPlayer player = (EntityPlayer) listener;
        player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult));
    }
}
Also used : EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_11_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 30 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    if (!world.isClientSide) {
        EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
        ItemStack itemstack = ItemStack.a;
        IRecipe irecipe = CraftingManager.b(craftInventory, world);
        if ((irecipe != null) && ((irecipe.c()) || (!world.getGameRules().getBoolean("doLimitedCrafting")) || (entityplayer.F().b(irecipe)))) {
            resultInventory.a(irecipe);
            itemstack = irecipe.craftItem(craftInventory);
        }
        itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, itemstack, getBukkitView(), false);
        resultInventory.setItem(0, itemstack);
        entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
        for (Object listener : listeners) {
            EntityPlayer player = (EntityPlayer) listener;
            player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
        }
    }
}
Also used : IRecipe(net.minecraft.server.v1_12_R1.IRecipe) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_12_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Aggregations

Player (org.bukkit.entity.Player)65 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)26 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)24 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)23 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)20 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)20 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)19 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)19 EntityPlayer (net.minecraft.server.v1_13_R2.EntityPlayer)19 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)18 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)17 GameProfile (com.mojang.authlib.GameProfile)16 MyPet (de.Keyle.MyPet.api.entity.MyPet)16 EntityPlayer (net.minecraft.server.v1_14_R1.EntityPlayer)16 OfflinePlayer (org.bukkit.OfflinePlayer)15 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)15 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)15 EntityPlayer (net.minecraft.server.v1_9_R2.EntityPlayer)13 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)13 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)13