use of org.bukkit.craftbukkit.v1_16_R1.CraftWorld in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftWorld in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftWorld in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method getResult.
@Override
public org.bukkit.inventory.ItemStack getResult(FishHook fishHook, CatchType catchType) {
ItemStack result = null;
EntityFishingHook nmsHook = ((CraftFishHook) fishHook).getHandle();
if (catchType == CatchType.DEFAULT) {
float f = ((CraftWorld) fishHook.getWorld()).getHandle().random.nextFloat();
int i = EnchantmentManager.g((EntityHuman) nmsHook.getShooter());
int j = EnchantmentManager.a(Enchantments.LURE, (EntityHuman) nmsHook.getShooter());
float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
f1 = MathHelper.a(f1, 0.0F, 1.0F);
f2 = MathHelper.a(f2, 0.0F, 1.0F);
if (f < f1) {
result = catchRandomJunk(nmsHook);
} else {
f -= f1;
if (f < f2) {
result = catchRandomTreasure(nmsHook);
} else {
result = catchRandomFish(nmsHook);
}
}
} else if (catchType == CatchType.JUNK) {
result = catchRandomJunk(nmsHook);
} else if (catchType == CatchType.TREASURE) {
result = catchRandomTreasure(nmsHook);
} else if (catchType == CatchType.FISH) {
result = catchRandomFish(nmsHook);
}
if (result != null) {
return CraftItemStack.asBukkitCopy(result);
} else {
return null;
}
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showBlockAction.
@Override
public void showBlockAction(Player player, Location location, int action, int state) {
BlockPosition position = new BlockPosition(location.getX(), location.getY(), location.getZ());
Block block = ((CraftWorld) location.getWorld()).getHandle().getType(position).getBlock();
sendPacket(player, new PacketPlayOutBlockAction(position, block, action, state));
}
Aggregations