use of net.minecraft.server.v1_16_R2.World in project UltraCosmetics by iSach.
the class MorphElderGuardian method onEquip.
@Override
protected void onEquip() {
super.onEquip();
World world = ((CraftWorld) getPlayer().getWorld()).getHandle();
customGuardian = new CustomGuardian(EntityTypes.ELDER_GUARDIAN, world);
customEntities.add(customGuardian);
customGuardian.check();
Location location = getPlayer().getLocation();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
customGuardian.setLocation(x, y, z, 0, 0);
EntitySpawningManager.setBypass(true);
world.addEntity(customGuardian);
EntitySpawningManager.setBypass(false);
getPlayer().setPassenger(customGuardian.getBukkitEntity());
customGuardian.setInvisible(true);
}
use of net.minecraft.server.v1_16_R2.World in project UltraCosmetics by iSach.
the class EntityUtil method playChestAnimation.
@Override
public void playChestAnimation(Block b, boolean open, TreasureChestDesign design) {
Location location = b.getLocation();
World world = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition position = new BlockPosition(location.getX(), location.getY(), location.getZ());
if (design.getChestType() == ChestType.ENDER) {
TileEntityEnderChest tileChest = (TileEntityEnderChest) world.getTileEntity(position);
world.playBlockAction(position, tileChest.w(), 1, open ? 1 : 0);
} else {
TileEntityChest tileChest = (TileEntityChest) world.getTileEntity(position);
world.playBlockAction(position, tileChest.w(), 1, open ? 1 : 0);
}
}
use of net.minecraft.server.v1_16_R2.World in project SimplePets by brainsynder-Dev.
the class SpawnUtil method spawn.
public IEntityPet spawn(Location l, IPet pet, String className) {
try {
World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
customEntity.setInvisible(false);
customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
if (customEntity instanceof IEntityControllerPet) {
if (pet.getPetType() instanceof ArmorStandDefault) {
ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
stand.setGravity(false);
stand.setArms(true);
stand.setCollidable(false);
stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
} else if (pet.getPetType() instanceof ShulkerDefault) {
ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
stand.setGravity(false);
stand.setCollidable(false);
stand.setSmall(true);
Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
shulker.setAI(false);
shulker.setCollidable(false);
stand.addPassenger(shulker);
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
}
}
return customEntity;
} catch (Exception e) {
e.printStackTrace();
throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
}
}
use of net.minecraft.server.v1_16_R2.World in project UltraCosmetics by iSach.
the class MorphElderGuardian method onEquip.
@Override
protected void onEquip() {
super.onEquip();
World world = ((CraftWorld) getPlayer().getWorld()).getHandle();
customGuardian = new CustomGuardian(world);
customEntities.add(customGuardian);
customGuardian.check();
Location location = getPlayer().getLocation();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
customGuardian.setLocation(x, y, z, 0, 0);
EntitySpawningManager.setBypass(true);
world.addEntity(customGuardian);
EntitySpawningManager.setBypass(false);
getPlayer().setPassenger(customGuardian.getBukkitEntity());
customGuardian.setInvisible(true);
}
use of net.minecraft.server.v1_16_R2.World in project SimplePets by brainsynder-Dev.
the class SpawnUtil method spawn.
public IEntityPet spawn(Location l, IPet pet, String className) {
try {
World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
customEntity.setInvisible(false);
customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
if (customEntity instanceof IEntityControllerPet) {
if (pet.getPetType() instanceof ArmorStandDefault) {
ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
stand.setGravity(false);
stand.setArms(true);
stand.setCollidable(false);
stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
} else if (pet.getPetType() instanceof ShulkerDefault) {
ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
stand.setGravity(false);
stand.setCollidable(false);
stand.setSmall(true);
Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
shulker.setAI(false);
shulker.setCollidable(false);
((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
}
}
return customEntity;
} catch (Exception e) {
e.printStackTrace();
throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
}
}
Aggregations