use of org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class BehaviorDuelTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
} else if (!petEntity.hasTarget()) {
return true;
}
LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.getBehavior() != BehaviorMode.Duel) {
return true;
} else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return true;
} else if (target.level != petEntity.level) {
return true;
} else if (petEntity.distanceToSqr(target) > 400) {
return true;
} else
return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
use of org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method getPlayerLanguage.
public String getPlayerLanguage(Player player) {
if (!(player instanceof CraftPlayer)) {
return "en_US";
}
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
try {
Field field = entityPlayer.getClass().getDeclaredField("locale");
String lang = field.get(entityPlayer).toString();
if (lang == null) {
return "en_US";
}
return lang;
} catch (Exception e) {
return "en_US";
}
}
use of org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class CustomInventory method open.
@Override
public void open(Player player) {
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
AbstractContainerMenu container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
if (container != null) {
MenuType<?> customSize = MenuType.GENERIC_9x1;
switch(this.getContainerSize()) {
case 18:
customSize = MenuType.GENERIC_9x2;
break;
case 27:
customSize = MenuType.GENERIC_9x3;
break;
case 36:
customSize = MenuType.GENERIC_9x4;
break;
case 45:
customSize = MenuType.GENERIC_9x5;
break;
case 54:
customSize = MenuType.GENERIC_9x6;
break;
}
entityPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, customSize, new TextComponent(this.getName())));
entityPlayer.containerMenu = container;
entityPlayer.initMenu(container);
}
}
use of org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class BehaviorFarmTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
}
if (!this.petEntity.hasTarget()) {
return true;
}
EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
if (!target.isAlive()) {
return true;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.getBehavior() != BehaviorMode.Farm) {
return true;
} else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return true;
} else if (target.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
return true;
}
return false;
}
use of org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer in project solinia3-core by mixxit.
the class ForgeUtils method sendForgeMessage.
public static void sendForgeMessage(Player player, String channelName, byte discriminator, String message) throws Exception {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(stream);
try {
// diesieben07 - Forge uses an unsigned byte for the discriminator, for a start
// dataOut.writeInt(discriminator);
dataOut.writeByte(discriminator);
// diesieben07 - But you should really send some kind of length prefix
// and then only read that much of the string
// You're already using DataOuput, it has writeUTFString
// dataOut.write(message.getBytes(StandardCharsets.UTF_8));
dataOut.writeUTF(message);
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channelName), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
} finally {
dataOut.close();
stream.close();
}
}
Aggregations