Search in sources :

Example 86 with CraftWorld

use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method setSpawnerSpawnedType.

@Override
public void setSpawnerSpawnedType(CreatureSpawner spawner, EntityTag entity) {
    spawner.setSpawnedType(entity.getBukkitEntityType());
    if (entity.getWaitingMechanisms() == null || entity.getWaitingMechanisms().size() == 0) {
        return;
    }
    try {
        // Wrangle a fake entity
        Entity nmsEntity = ((CraftWorld) spawner.getWorld()).createEntity(spawner.getLocation(), entity.getBukkitEntityType().getEntityClass());
        EntityTag entityTag = new EntityTag(nmsEntity.getBukkitEntity());
        entityTag.isFake = true;
        entityTag.isFakeValid = true;
        for (Mechanism mechanism : entity.getWaitingMechanisms()) {
            entityTag.safeAdjustDuplicate(mechanism);
        }
        nmsEntity.unsetRemoved();
        // Store it into the spawner
        CraftCreatureSpawner bukkitSpawner = (CraftCreatureSpawner) spawner;
        SpawnerBlockEntity nmsSnapshot = (SpawnerBlockEntity) craftBlockEntityState_snapshot.get(bukkitSpawner);
        BaseSpawner nmsSpawner = nmsSnapshot.getSpawner();
        SpawnData toSpawn = nmsSpawner.nextSpawnData;
        net.minecraft.nbt.CompoundTag tag = toSpawn.getEntityToSpawn();
        nmsEntity.saveWithoutId(tag);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) Entity(net.minecraft.world.entity.Entity) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) BaseSpawner(net.minecraft.world.level.BaseSpawner) EntityTag(com.denizenscript.denizen.objects.EntityTag) SpawnData(net.minecraft.world.level.SpawnData) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) Mechanism(com.denizenscript.denizencore.objects.Mechanism)

Example 87 with CraftWorld

use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class CustomEntityHelperImpl method spawnItemProjectile.

@Override
public ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack) {
    CraftWorld world = (CraftWorld) location.getWorld();
    EntityItemProjectileImpl entity = new EntityItemProjectileImpl(world.getHandle(), location, CraftItemStack.asNMSCopy(itemStack));
    world.getHandle().addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return entity.getBukkitEntity();
}
Also used : EntityItemProjectileImpl(com.denizenscript.denizen.nms.v1_18.impl.entities.EntityItemProjectileImpl) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 88 with CraftWorld

use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class CustomEntityHelperImpl method spawnFakeArrow.

@Override
public FakeArrow spawnFakeArrow(Location location) {
    CraftWorld world = (CraftWorld) location.getWorld();
    EntityFakeArrowImpl arrow = new EntityFakeArrowImpl(world, location);
    return arrow.getBukkitEntity();
}
Also used : EntityFakeArrowImpl(com.denizenscript.denizen.nms.v1_18.impl.entities.EntityFakeArrowImpl) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 89 with CraftWorld

use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class WorldHelperImpl method setStatic.

@Override
public void setStatic(World world, boolean isStatic) {
    ServerLevel worldServer = ((CraftWorld) world).getHandle();
    ReflectionHelper.setFieldValue(net.minecraft.world.level.Level.class, ReflectionMappingsInfo.Level_isClientSide, worldServer, isStatic);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 90 with CraftWorld

use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method setTrackingRange.

@Override
public void setTrackingRange(Entity entity, int range) {
    try {
        ChunkMap map = ((CraftWorld) entity.getWorld()).getHandle().getChunkProvider().chunkMap;
        ChunkMap.TrackedEntity entry = map.G.get(entity.getEntityId());
        TRACKING_RANGE_SETTER.invoke(entry, range);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : ChunkMap(net.minecraft.server.level.ChunkMap) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)63 Location (org.bukkit.Location)56 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)42 ItemStack (org.bukkit.inventory.ItemStack)42 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)40 BlockPos (net.minecraft.core.BlockPos)36 Zombie (org.bukkit.entity.Zombie)32 LivingEntity (org.bukkit.entity.LivingEntity)29 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)28 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)28 ItemEntity (net.minecraft.world.entity.item.ItemEntity)27 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)26 HangingEntity (net.minecraft.world.entity.decoration.HangingEntity)25 FallingBlockEntity (net.minecraft.world.entity.item.FallingBlockEntity)25 FireworkRocketEntity (net.minecraft.world.entity.projectile.FireworkRocketEntity)25 SignBlockEntity (net.minecraft.world.level.block.entity.SignBlockEntity)25 Entity (org.bukkit.entity.Entity)25 HumanEntity (org.bukkit.entity.HumanEntity)25 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)23 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)17