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();
}
}
}
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();
}
}
}
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;
}
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));
}
}
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));
}
}
}
Aggregations