Search in sources :

Example 51 with WorldServer

use of net.minecraft.server.v1_15_R1.WorldServer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.bZ();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    itemStack.a(worldServer, blockData.getBlock(), blockPosition, entityPlayer);
    if (itemStack.count == 0)
        entityPlayer.ca();
}
Also used : IBlockData(net.minecraft.server.v1_8_R3.IBlockData) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 52 with WorldServer

use of net.minecraft.server.v1_15_R1.WorldServer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.getItemInMainHand();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    assert itemStack != null;
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) ItemStack(net.minecraft.server.v1_12_R1.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 53 with WorldServer

use of net.minecraft.server.v1_15_R1.WorldServer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.removeTileEntity(blockPosition);
    location.getBlock().setType(type);
    if (nbt != null) {
        try {
            ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
            ArgumentTileLocation tileLocation = new ArgumentTileLocation(argumentBlock.getBlockData(), argumentBlock.getStateMap().keySet(), argumentBlock.c());
            tileLocation.a(worldServer, blockPosition, 2);
            worldServer.update(blockPosition, tileLocation.a().getBlock());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : ArgumentTileLocation(net.minecraft.server.v1_16_R3.ArgumentTileLocation) ArgumentBlock(net.minecraft.server.v1_16_R3.ArgumentBlock) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) StringReader(com.mojang.brigadier.StringReader) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 54 with WorldServer

use of net.minecraft.server.v1_15_R1.WorldServer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.getItemInMainHand();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    assert itemStack != null;
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.server.v1_16_R3.IBlockData) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 55 with WorldServer

use of net.minecraft.server.v1_15_R1.WorldServer in project Movecraft by APDevTeam.

the class IWorldHandler method rotateCraft.

@Override
public void rotateCraft(@NotNull Craft craft, @NotNull MovecraftLocation originPoint, @NotNull MovecraftRotation rotation) {
    // *******************************************
    // *      Step one: Convert to Positions     *
    // *******************************************
    HashMap<BlockPosition, BlockPosition> rotatedPositions = new HashMap<>();
    MovecraftRotation counterRotation = rotation == MovecraftRotation.CLOCKWISE ? MovecraftRotation.ANTICLOCKWISE : MovecraftRotation.CLOCKWISE;
    for (MovecraftLocation newLocation : craft.getHitBox()) {
        rotatedPositions.put(locationToPosition(MathUtils.rotateVec(counterRotation, newLocation.subtract(originPoint)).add(originPoint)), locationToPosition(newLocation));
    }
    // *******************************************
    // *         Step two: Get the tiles         *
    // *******************************************
    WorldServer nativeWorld = ((CraftWorld) craft.getWorld()).getHandle();
    List<TileHolder> tiles = new ArrayList<>();
    // get the tiles
    for (BlockPosition position : rotatedPositions.keySet()) {
        // TileEntity tile = nativeWorld.removeTileEntity(position);
        TileEntity tile = removeTileEntity(nativeWorld, position);
        if (tile == null)
            continue;
        tile.a(ROTATION[rotation.ordinal()]);
        // get the nextTick to move with the tile
        tiles.add(new TileHolder(tile, tickProvider.getNextTick(nativeWorld, position), position));
    }
    // *******************************************
    // *   Step three: Translate all the blocks  *
    // *******************************************
    // blockedByWater=false means an ocean-going vessel
    // TODO: Simplify
    // TODO: go by chunks
    // TODO: Don't move unnecessary blocks
    // get the blocks and rotate them
    HashMap<BlockPosition, IBlockData> blockData = new HashMap<>();
    for (BlockPosition position : rotatedPositions.keySet()) {
        blockData.put(position, nativeWorld.getType(position).a(ROTATION[rotation.ordinal()]));
    }
    // create the new block
    for (Map.Entry<BlockPosition, IBlockData> entry : blockData.entrySet()) {
        setBlockFast(nativeWorld, rotatedPositions.get(entry.getKey()), entry.getValue());
    }
    // TODO: go by chunks
    for (TileHolder tileHolder : tiles) {
        moveTileEntity(nativeWorld, rotatedPositions.get(tileHolder.getTilePosition()), tileHolder.getTile());
        if (tileHolder.getNextTick() == null)
            continue;
        final long currentTime = nativeWorld.worldData.getTime();
        nativeWorld.getBlockTickList().a(rotatedPositions.get(tileHolder.getNextTick().a), (Block) tileHolder.getNextTick().b(), (int) (tileHolder.getNextTick().b - currentTime), tileHolder.getNextTick().c);
    }
    // *******************************************
    // *   Step five: Destroy the leftovers      *
    // *******************************************
    // TODO: add support for pass-through
    Collection<BlockPosition> deletePositions = CollectionUtils.filter(rotatedPositions.keySet(), rotatedPositions.values());
    for (BlockPosition position : deletePositions) {
        setBlockFast(nativeWorld, position, Blocks.AIR.getBlockData());
    }
}
Also used : HashMap(java.util.HashMap) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) MovecraftRotation(net.countercraft.movecraft.MovecraftRotation) TileEntity(net.minecraft.server.v1_16_R3.TileEntity) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) MovecraftLocation(net.countercraft.movecraft.MovecraftLocation) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

WorldServer (net.minecraft.server.v1_16_R3.WorldServer)24 WorldServer (net.minecraft.server.v1_12_R1.WorldServer)20 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)19 ArrayList (java.util.ArrayList)18 List (java.util.List)16 UUID (java.util.UUID)16 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)16 GameProfile (com.mojang.authlib.GameProfile)15 WorldServer (net.minecraft.server.v1_11_R1.WorldServer)15 Material (org.bukkit.Material)15 WorldServer (net.minecraft.server.v1_14_R1.WorldServer)14 WorldServer (net.minecraft.server.v1_15_R1.WorldServer)14 WorldServer (net.minecraft.server.v1_10_R1.WorldServer)13 Block (org.bukkit.block.Block)13 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)13 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)12 WorldServer (net.minecraft.server.v1_8_R3.WorldServer)12 LivingEntity (org.bukkit.entity.LivingEntity)12 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)11 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)11