Search in sources :

Example 21 with World

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

the class NMSInventory_v1_12_R1 method updateTileEntity.

@Override
public void updateTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity tileEntity = world.getTileEntity(blockPosition);
    TileEntityWildChest tileEntityWildChest;
    if (tileEntity instanceof TileEntityWildChest) {
        tileEntityWildChest = (TileEntityWildChest) tileEntity;
        ((WChest) chest).setTileEntityContainer(tileEntityWildChest);
    } else {
        tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
    }
    world.setTileEntity(blockPosition, tileEntityWildChest);
}
Also used : TileEntity(net.minecraft.server.v1_12_R1.TileEntity) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) World(net.minecraft.server.v1_12_R1.World) WChest(com.bgsoftware.wildchests.objects.chests.WChest) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Location(org.bukkit.Location)

Example 22 with World

use of net.minecraft.server.v1_16_R2.World in project InteractionVisualizer by LOOHP.

the class V1_16_2 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_16_R2.BlockPosition blockpos = new net.minecraft.server.v1_16_R2.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) EnumItemSlot(net.minecraft.server.v1_16_R2.EnumItemSlot) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) CraftMagicNumbers(org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) CraftChunk(org.bukkit.craftbukkit.v1_16_R2.CraftChunk) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) EntityItem(net.minecraft.server.v1_16_R2.EntityItem) CraftItem(org.bukkit.craftbukkit.v1_16_R2.entity.CraftItem) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 23 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_R2.IBlockData) World(net.minecraft.server.v1_16_R2.World)

Example 24 with World

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

the class StackedSpawnerTileImpl method c.

@Override
public void c() {
    World level = this.a();
    if (level == null)
        return;
    // Only tick the spawner if a player is nearby
    this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
    if (this.playersTimeSinceLastCheck == 0)
        this.playersNearby = this.isNearPlayer(level, this.blockPos);
    if (!this.playersNearby)
        return;
    SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
    // Handle redstone deactivation if enabled
    if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
        if (this.redstoneTimeSinceLastCheck == 0) {
            boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
            if (this.redstoneDeactivated && !hasSignal) {
                this.redstoneDeactivated = false;
                this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
                this.updateTile();
            } else if (!this.redstoneDeactivated && hasSignal) {
                this.redstoneDeactivated = true;
                this.requiredPlayerRange = 0;
                this.updateTile();
            }
            if (this.redstoneDeactivated)
                return;
        }
        this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
    }
    // Count down spawn timer unless we are ready to spawn
    if (this.spawnDelay > 0) {
        this.spawnDelay--;
        return;
    }
    // Reset spawn delay
    this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
    this.updateTile();
    // Execute spawning method
    if (this.spawnData != null) {
        MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
        if (resourceLocation != null) {
            NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
            EntityType entityType = this.fromKey(namespacedKey);
            if (entityType != null)
                new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
        }
    }
    // Randomize spawn potentials
    if (!this.mobs.isEmpty())
        this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
Also used : EntityType(org.bukkit.entity.EntityType) SpawnerStackSettings(dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings) MobSpawningMethod(dev.rosewood.rosestacker.spawner.spawning.MobSpawningMethod) CraftNamespacedKey(org.bukkit.craftbukkit.v1_16_R2.util.CraftNamespacedKey) NamespacedKey(org.bukkit.NamespacedKey) World(net.minecraft.server.v1_16_R2.World) MinecraftKey(net.minecraft.server.v1_16_R2.MinecraftKey)

Example 25 with World

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

the class StackedSpawnerTileImpl method c.

@Override
public void c() {
    World level = this.a();
    if (level == null)
        return;
    // Only tick the spawner if a player is nearby
    this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
    if (this.playersTimeSinceLastCheck == 0)
        this.playersNearby = this.isNearPlayer(level, this.blockPos);
    if (!this.playersNearby)
        return;
    SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
    // Handle redstone deactivation if enabled
    if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
        if (this.redstoneTimeSinceLastCheck == 0) {
            boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
            if (this.redstoneDeactivated && !hasSignal) {
                this.redstoneDeactivated = false;
                this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
                this.updateTile();
            } else if (!this.redstoneDeactivated && hasSignal) {
                this.redstoneDeactivated = true;
                this.requiredPlayerRange = 0;
                this.updateTile();
            }
            if (this.redstoneDeactivated)
                return;
        }
        this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
    }
    // Count down spawn timer unless we are ready to spawn
    if (this.spawnDelay > 0) {
        this.spawnDelay--;
        return;
    }
    // Reset spawn delay
    this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
    this.updateTile();
    // Execute spawning method
    if (this.spawnData != null) {
        MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
        if (resourceLocation != null) {
            NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
            EntityType entityType = this.fromKey(namespacedKey);
            if (entityType != null)
                new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
        }
    }
    // Randomize spawn potentials
    if (!this.mobs.isEmpty())
        this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
Also used : EntityType(org.bukkit.entity.EntityType) SpawnerStackSettings(dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings) MobSpawningMethod(dev.rosewood.rosestacker.spawner.spawning.MobSpawningMethod) NamespacedKey(org.bukkit.NamespacedKey) CraftNamespacedKey(org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey) World(net.minecraft.server.v1_16_R3.World) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey)

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