use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class CustomInventory method open.
@Override
public void open(Player player) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
if (container != null) {
Containers customSize = Containers.GENERIC_9X1;
switch(this.getSize()) {
case 18:
customSize = Containers.GENERIC_9X2;
break;
case 27:
customSize = Containers.GENERIC_9X3;
break;
case 36:
customSize = Containers.GENERIC_9X4;
break;
case 45:
customSize = Containers.GENERIC_9X5;
break;
case 54:
customSize = Containers.GENERIC_9X6;
break;
}
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, customSize, new ChatComponentText(this.getName())));
entityPlayer.activeContainer = container;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
}
use of org.bukkit.craftbukkit.v1_18_R2.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;
}
EntityLiving 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.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else
return petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
use of org.bukkit.craftbukkit.v1_18_R2.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;
}
net.minecraft.world.entity.LivingEntity 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.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_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat<Object> data) {
EnumParticle effect;
try {
effect = EnumParticle.valueOf(effectName);
} catch (IllegalArgumentException e) {
effect = EnumParticle.a(effectName);
}
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effect, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
int[] intData = data != null ? (int[]) data.get() : new int[0];
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effect, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, intData);
radius = radius * radius;
for (Player player : location.getWorld().getPlayers()) {
if ((int) MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}
use of org.bukkit.craftbukkit.v1_18_R2.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;
}
EntityLiving 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.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;
}
Aggregations