Search in sources :

Example 66 with World

use of net.minecraft.server.v1_13_R1.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);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) World(net.minecraft.server.v1_15_R1.World) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) EntityControllerPet(simplepets.brainsynder.nms.v1_15_R1.entities.list.EntityControllerPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 67 with World

use of net.minecraft.server.v1_13_R1.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();
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(World.class, IPet.class).newInstance(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.setPassenger(shulker);
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) EntityControllerPet(simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) World(net.minecraft.server.v1_11_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) EulerAngle(org.bukkit.util.EulerAngle) Shulker(org.bukkit.entity.Shulker) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet)

Example 68 with World

use of net.minecraft.server.v1_13_R1.World in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method updateSpawner.

@Override
public void updateSpawner(Location location, boolean reset) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityMobSpawner mobSpawner = (TileEntityMobSpawner) world.getTileEntity(blockPosition);
    NBTTagCompound nbtTagCompound = new NBTTagCompound();
    mobSpawner.b(nbtTagCompound);
    nbtTagCompound.setShort("RequiredPlayerRange", (short) (reset ? 16 : -1));
    mobSpawner.a(nbtTagCompound);
}
Also used : BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) TileEntityMobSpawner(net.minecraft.server.v1_8_R3.TileEntityMobSpawner) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 69 with World

use of net.minecraft.server.v1_13_R1.World in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method removeLoader.

@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
    Location loaderLoc = chunkLoader.getLocation();
    World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
    long tileEntityLong = LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
    TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
    if (tileEntityChunkLoader != null) {
        tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_8_R3::removeHologram);
        tileEntityChunkLoader.removed = true;
        world.tileEntityList.remove(tileEntityChunkLoader);
    }
    if (spawnParticle)
        world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
    for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
        Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
        chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
            NBTTagCompound nbtTagCompound = new NBTTagCompound();
            tileEntity.b(nbtTagCompound);
            nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
            tileEntity.a(nbtTagCompound);
        });
    }
}
Also used : ChunkLoader(com.bgsoftware.wildloaders.api.loaders.ChunkLoader) NBTTagList(net.minecraft.server.v1_8_R3.NBTTagList) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) HashMap(java.util.HashMap) IUpdatePlayerListBox(net.minecraft.server.v1_8_R3.IUpdatePlayerListBox) ArrayList(java.util.ArrayList) WChunkLoader(com.bgsoftware.wildloaders.loaders.WChunkLoader) Location(org.bukkit.Location) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) Map(java.util.Map) TileEntityMobSpawner(net.minecraft.server.v1_8_R3.TileEntityMobSpawner) WildLoadersPlugin(com.bgsoftware.wildloaders.WildLoadersPlugin) LongHash(org.bukkit.craftbukkit.v1_8_R3.util.LongHash) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) TileEntity(net.minecraft.server.v1_8_R3.TileEntity) Hologram(com.bgsoftware.wildloaders.api.holograms.Hologram) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) NBTTagLong(net.minecraft.server.v1_8_R3.NBTTagLong) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Collection(java.util.Collection) UUID(java.util.UUID) Block(net.minecraft.server.v1_8_R3.Block) World(net.minecraft.server.v1_8_R3.World) List(java.util.List) Chunk(net.minecraft.server.v1_8_R3.Chunk) ChunkLoaderNPC(com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Collections(java.util.Collections) NBTTagString(net.minecraft.server.v1_8_R3.NBTTagString) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Chunk(net.minecraft.server.v1_8_R3.Chunk) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_8_R3.TileEntityMobSpawner) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Location(org.bukkit.Location)

Example 70 with World

use of net.minecraft.server.v1_13_R1.World in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_7_R4 method removeLoader.

@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
    Location loaderLoc = chunkLoader.getLocation();
    World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
    int x = loaderLoc.getBlockX(), y = loaderLoc.getBlockY(), z = loaderLoc.getBlockZ();
    long tileEntityLong = LongHash.toLong(x >> 4, z >> 4);
    TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
    if (tileEntityChunkLoader != null) {
        tileEntityChunkLoader.removed = true;
        world.tileEntityList.remove(tileEntityChunkLoader);
    }
    if (spawnParticle)
        world.a(null, 2001, x, y, z, Block.getId(world.getType(x, y, z)) + (world.getData(x, y, z) << 12));
    for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
        Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
        // noinspection unchecked
        chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
            NBTTagCompound nbtTagCompound = new NBTTagCompound();
            ((TileEntity) tileEntity).b(nbtTagCompound);
            nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
            ((TileEntity) tileEntity).a(nbtTagCompound);
        });
    }
}
Also used : ChunkLoader(com.bgsoftware.wildloaders.api.loaders.ChunkLoader) IUpdatePlayerListBox(net.minecraft.server.v1_7_R4.IUpdatePlayerListBox) NBTTagString(net.minecraft.server.v1_7_R4.NBTTagString) HashMap(java.util.HashMap) TileEntity(net.minecraft.server.v1_7_R4.TileEntity) LongHash(org.bukkit.craftbukkit.v1_7_R4.util.LongHash) WChunkLoader(com.bgsoftware.wildloaders.loaders.WChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_7_R4.TileEntityMobSpawner) Location(org.bukkit.Location) Map(java.util.Map) WildLoadersPlugin(com.bgsoftware.wildloaders.WildLoadersPlugin) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) NBTTagList(net.minecraft.server.v1_7_R4.NBTTagList) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) Hologram(com.bgsoftware.wildloaders.api.holograms.Hologram) NBTTagLong(net.minecraft.server.v1_7_R4.NBTTagLong) Collection(java.util.Collection) UUID(java.util.UUID) NBTTagCompound(net.minecraft.server.v1_7_R4.NBTTagCompound) Block(net.minecraft.server.v1_7_R4.Block) Chunk(net.minecraft.server.v1_7_R4.Chunk) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack) ChunkLoaderNPC(com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC) World(net.minecraft.server.v1_7_R4.World) Collections(java.util.Collections) NBTTagCompound(net.minecraft.server.v1_7_R4.NBTTagCompound) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) World(net.minecraft.server.v1_7_R4.World) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) Chunk(net.minecraft.server.v1_7_R4.Chunk) TileEntity(net.minecraft.server.v1_7_R4.TileEntity) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_7_R4.TileEntityMobSpawner) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) Location(org.bukkit.Location)

Aggregations

Location (org.bukkit.Location)26 World (net.minecraft.server.v1_16_R3.World)16 World (net.minecraft.server.v1_12_R1.World)15 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)15 World (net.minecraft.server.v1_8_R3.World)14 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)14 ArrayList (java.util.ArrayList)11 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)11 List (java.util.List)10 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)10 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)10 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8