Search in sources :

Example 6 with TileEntityMobSpawner

use of net.minecraft.server.v1_16_R3.TileEntityMobSpawner in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method injectStackedSpawnerTile.

@Override
public StackedSpawnerTile injectStackedSpawnerTile(Object stackedSpawnerObj) {
    StackedSpawner stackedSpawner = (StackedSpawner) stackedSpawnerObj;
    Block block = stackedSpawner.getBlock();
    WorldServer level = ((CraftWorld) block.getWorld()).getHandle();
    TileEntity blockEntity = level.getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
    if (blockEntity instanceof TileEntityMobSpawner) {
        TileEntityMobSpawner spawnerBlockEntity = (TileEntityMobSpawner) blockEntity;
        if (!(spawnerBlockEntity.getSpawner() instanceof StackedSpawnerTileImpl)) {
            StackedSpawnerTile stackedSpawnerTile = new StackedSpawnerTileImpl(spawnerBlockEntity.getSpawner(), spawnerBlockEntity, stackedSpawner);
            unsafe.putObject(spawnerBlockEntity, field_SpawnerBlockEntity_spawner_offset, stackedSpawnerTile);
            return stackedSpawnerTile;
        } else {
            StackedSpawnerTileImpl spawnerTile = (StackedSpawnerTileImpl) spawnerBlockEntity.getSpawner();
            spawnerTile.updateStackedSpawner(stackedSpawner);
            return spawnerTile;
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.server.v1_16_R2.TileEntity) StackedSpawner(dev.rosewood.rosestacker.stack.StackedSpawner) BlockPosition(net.minecraft.server.v1_16_R2.BlockPosition) Block(org.bukkit.block.Block) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) TileEntityMobSpawner(net.minecraft.server.v1_16_R2.TileEntityMobSpawner) StackedSpawnerTileImpl(dev.rosewood.rosestacker.nms.v1_16_R2.spawner.StackedSpawnerTileImpl) StackedSpawnerTile(dev.rosewood.rosestacker.nms.spawner.StackedSpawnerTile) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 7 with TileEntityMobSpawner

use of net.minecraft.server.v1_16_R3.TileEntityMobSpawner in project SilkSpawners by timbru31.

the class NMSHandler method getMobNameOfSpawner.

@Override
public String getMobNameOfSpawner(final BlockState blockState) {
    // Get our spawner;
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    // Get the mob ID ourselves if we can
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        // Get the name from the field of our spawner
        final MinecraftKey minecraftKey = tile.getSpawner().getMobName();
        return minecraftKey != null ? minecraftKey.b() : "";
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return "";
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_11_R1.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_11_R1.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_11_R1.MinecraftKey)

Example 8 with TileEntityMobSpawner

use of net.minecraft.server.v1_16_R3.TileEntityMobSpawner in project SilkSpawners by timbru31.

the class NMSHandler method setMobNameOfSpawner.

@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
    // Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
    final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        tile.getSpawner().setMobName(new MinecraftKey(safeMobID));
        return true;
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return false;
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_12_R1.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_12_R1.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_12_R1.MinecraftKey)

Example 9 with TileEntityMobSpawner

use of net.minecraft.server.v1_16_R3.TileEntityMobSpawner in project SilkSpawners by timbru31.

the class NMSHandler method getMobNameOfSpawner.

@Override
public String getMobNameOfSpawner(final BlockState blockState) {
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        final MinecraftKey minecraftKey = tile.getSpawner().getMobName();
        return minecraftKey != null ? minecraftKey.getKey() : "";
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return "";
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_13_R2.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_13_R2.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_13_R2.MinecraftKey)

Example 10 with TileEntityMobSpawner

use of net.minecraft.server.v1_16_R3.TileEntityMobSpawner in project SilkSpawners by timbru31.

the class NMSHandler method getMobNameOfSpawner.

@Override
public String getMobNameOfSpawner(final BlockState blockState) {
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        final MinecraftKey minecraftKey = tile.getSpawner().getMobName();
        return minecraftKey != null ? minecraftKey.getKey() : "";
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return "";
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_15_R1.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_15_R1.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_15_R1.MinecraftKey)

Aggregations

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 HashMap (java.util.HashMap)8 Map (java.util.Map)8 UUID (java.util.UUID)8 Location (org.bukkit.Location)8 ArrayList (java.util.ArrayList)6 List (java.util.List)6 TileEntityMobSpawner (net.minecraft.server.v1_16_R3.TileEntityMobSpawner)6 TileEntityMobSpawner (net.minecraft.server.v1_12_R1.TileEntityMobSpawner)5 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)4 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)3 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)3 TileEntityMobSpawner (net.minecraft.server.v1_16_R2.TileEntityMobSpawner)3