Search in sources :

Example 26 with World

use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.

the class StackedSpawnerTileImpl method updateTile.

private void updateTile() {
    World level = this.a();
    if (level != null) {
        level.b(this.blockPos, this.blockEntity);
        IBlockData var1 = this.a().getType(this.b());
        this.a().notify(this.blockPos, var1, var1, 3);
    }
}
Also used : IBlockData(net.minecraft.server.v1_16_R3.IBlockData) World(net.minecraft.server.v1_16_R3.World)

Example 27 with World

use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createEntityFromNBT.

@Override
public LivingEntity createEntityFromNBT(StackedEntityDataEntry<?> serialized, Location location, boolean addToWorld, EntityType entityType) {
    try {
        NBTTagCompound nbt = (NBTTagCompound) serialized.get();
        NBTTagList positionTagList = nbt.getList("Pos", 6);
        if (positionTagList == null)
            positionTagList = new NBTTagList();
        this.setTag(positionTagList, 0, NBTTagDouble.a(location.getX()));
        this.setTag(positionTagList, 1, NBTTagDouble.a(location.getY()));
        this.setTag(positionTagList, 2, NBTTagDouble.a(location.getZ()));
        nbt.set("Pos", positionTagList);
        NBTTagList rotationTagList = nbt.getList("Rotation", 5);
        if (rotationTagList == null)
            rotationTagList = new NBTTagList();
        this.setTag(rotationTagList, 0, NBTTagFloat.a(location.getYaw()));
        this.setTag(rotationTagList, 1, NBTTagFloat.a(location.getPitch()));
        nbt.set("Rotation", rotationTagList);
        // Reset the UUID to resolve possible duplicates
        nbt.a("UUID", UUID.randomUUID());
        Optional<EntityTypes<?>> optionalEntity = EntityTypes.a(entityType.getKey().getKey());
        if (optionalEntity.isPresent()) {
            WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
            Entity entity = this.createCreature(optionalEntity.get(), world, nbt, null, null, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), EnumMobSpawn.COMMAND);
            if (entity == null)
                throw new NullPointerException("Unable to create entity from NBT");
            // Load NBT
            entity.load(nbt);
            if (addToWorld) {
                IChunkAccess ichunkaccess = world.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, true);
                if (!(ichunkaccess instanceof Chunk))
                    throw new NullPointerException("Unable to spawn entity from NBT, couldn't get chunk");
                ichunkaccess.a(entity);
                method_WorldServer_registerEntity.invoke(world, entity);
                entity.noDamageTicks = 0;
            }
            return (LivingEntity) entity.getBukkitEntity();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : EntityTypes(net.minecraft.server.v1_16_R2.EntityTypes) IChunkAccess(net.minecraft.server.v1_16_R2.IChunkAccess) Entity(net.minecraft.server.v1_16_R2.Entity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) TileEntity(net.minecraft.server.v1_16_R2.TileEntity) GroupDataEntity(net.minecraft.server.v1_16_R2.GroupDataEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity) BlockPosition(net.minecraft.server.v1_16_R2.BlockPosition) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) Chunk(net.minecraft.server.v1_16_R2.Chunk) NBTTagList(net.minecraft.server.v1_16_R2.NBTTagList) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 28 with World

use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createNewEntityUnspawned.

@Override
public LivingEntity createNewEntityUnspawned(EntityType entityType, Location location, SpawnReason spawnReason) {
    World world = location.getWorld();
    if (world == null)
        return null;
    Class<? extends org.bukkit.entity.Entity> entityClass = entityType.getEntityClass();
    if (entityClass == null || !LivingEntity.class.isAssignableFrom(entityClass))
        throw new IllegalArgumentException("EntityType must be of a LivingEntity");
    EntityTypes<? extends Entity> nmsEntityType = IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(entityType.getKey()));
    Entity nmsEntity = this.createCreature(nmsEntityType, ((CraftWorld) world).getHandle(), null, null, null, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), this.toNmsSpawnReason(spawnReason));
    return nmsEntity == null ? null : (LivingEntity) nmsEntity.getBukkitEntity();
}
Also used : Entity(net.minecraft.server.v1_16_R2.Entity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) TileEntity(net.minecraft.server.v1_16_R2.TileEntity) GroupDataEntity(net.minecraft.server.v1_16_R2.GroupDataEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity) BlockPosition(net.minecraft.server.v1_16_R2.BlockPosition) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 29 with World

use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method spawnExistingEntity.

@Override
public void spawnExistingEntity(LivingEntity entity, SpawnReason spawnReason, boolean bypassSpawnEvent) {
    Location location = entity.getLocation();
    World world = location.getWorld();
    if (world == null)
        throw new IllegalArgumentException("Entity is not in a loaded world");
    if (bypassSpawnEvent) {
        IChunkAccess ichunkaccess = ((CraftWorld) world).getHandle().getChunkAt(MathHelper.floor(entity.getLocation().getX() / 16.0D), MathHelper.floor(entity.getLocation().getZ() / 16.0D), ChunkStatus.FULL, false);
        if (!(ichunkaccess instanceof Chunk))
            return;
        ichunkaccess.a(((CraftEntity) entity).getHandle());
        ((CraftWorld) world).getHandle().addEntityChunk(((CraftEntity) entity).getHandle());
    } else {
        ((CraftWorld) world).addEntity(((CraftEntity) entity).getHandle(), spawnReason);
    }
}
Also used : IChunkAccess(net.minecraft.server.v1_16_R2.IChunkAccess) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) Chunk(net.minecraft.server.v1_16_R2.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) Location(org.bukkit.Location)

Example 30 with World

use of net.minecraft.server.v1_16_R2.World in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_15_R1 method setChestName.

@Override
public void setChestName(Location chest, String name) {
    assert chest.getWorld() != null;
    World world = ((CraftWorld) chest.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(chest.getBlockX(), chest.getBlockY(), chest.getBlockZ());
    TileEntityChest tileEntityChest = (TileEntityChest) world.getTileEntity(blockPosition);
    assert tileEntityChest != null;
    tileEntityChest.setCustomName(CraftChatMessage.fromString(name)[0]);
}
Also used : TileEntityChest(net.minecraft.server.v1_15_R1.TileEntityChest) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) World(net.minecraft.server.v1_15_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Aggregations

Location (org.bukkit.Location)27 World (net.minecraft.server.v1_16_R3.World)16 World (net.minecraft.server.v1_12_R1.World)14 World (net.minecraft.server.v1_8_R3.World)14 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)14 ArrayList (java.util.ArrayList)12 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