Search in sources :

Example 91 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class v1_9_R2 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R2.AxisAlignedBB) IBlockData(net.minecraft.server.v1_9_R2.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition) Block(net.minecraft.server.v1_9_R2.Block) WorldServer(net.minecraft.server.v1_9_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Example 92 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class v1_10_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) IBlockData(net.minecraft.server.v1_10_R1.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) Block(net.minecraft.server.v1_10_R1.Block) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 93 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class v1_11_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.d(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_11_R1.AxisAlignedBB) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 94 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class v1_12_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.e(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 95 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project Movecraft by APDevTeam.

the class IWorldHandler method translateCraft.

@Override
public void translateCraft(@NotNull Craft craft, @NotNull MovecraftLocation displacement, @NotNull org.bukkit.World world) {
    // TODO: Add support for rotations
    // A craftTranslateCommand should only occur if the craft is moving to a valid position
    // *******************************************
    // *      Step one: Convert to Positions     *
    // *******************************************
    BlockPosition translateVector = locationToPosition(displacement);
    List<BlockPosition> positions = new ArrayList<>(craft.getHitBox().size());
    craft.getHitBox().forEach((movecraftLocation) -> positions.add(locationToPosition((movecraftLocation)).b(translateVector)));
    WorldServer oldNativeWorld = ((CraftWorld) craft.getWorld()).getHandle();
    World nativeWorld = ((CraftWorld) world).getHandle();
    // *******************************************
    // *         Step two: Get the tiles         *
    // *******************************************
    List<TileHolder> tiles = new ArrayList<>();
    // get the tiles
    for (int i = 0, positionsSize = positions.size(); i < positionsSize; i++) {
        BlockPosition position = positions.get(i);
        if (oldNativeWorld.getType(position) == Blocks.AIR.getBlockData())
            continue;
        // TileEntity tile = nativeWorld.removeTileEntity(position);
        TileEntity tile = removeTileEntity(oldNativeWorld, position);
        if (tile == null)
            continue;
        // get the nextTick to move with the tile
        // nativeWorld.capturedTileEntities.remove(position);
        // nativeWorld.getChunkAtWorldCoords(position).getTileEntities().remove(position);
        tiles.add(new TileHolder(tile, tickProvider.getNextTick(oldNativeWorld, 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 translate the positions
    List<IBlockData> blockData = new ArrayList<>();
    List<BlockPosition> newPositions = new ArrayList<>();
    for (int i = 0, positionsSize = positions.size(); i < positionsSize; i++) {
        BlockPosition position = positions.get(i);
        blockData.add(oldNativeWorld.getType(position));
        newPositions.add(position.a(translateVector));
    }
    // create the new block
    for (int i = 0, positionSize = newPositions.size(); i < positionSize; i++) {
        setBlockFast(nativeWorld, newPositions.get(i), blockData.get(i));
    }
    // TODO: go by chunks
    for (int i = 0, tilesSize = tiles.size(); i < tilesSize; i++) {
        TileHolder tileHolder = tiles.get(i);
        moveTileEntity(nativeWorld, tileHolder.getTilePosition().a(translateVector), tileHolder.getTile());
        if (tileHolder.getNextTick() == null)
            continue;
        final long currentTime = nativeWorld.worldData.getTime();
        nativeWorld.getBlockTickList().a(tileHolder.getNextTick().a.a(translateVector), (Block) tileHolder.getNextTick().b(), (int) (tileHolder.getNextTick().b - currentTime), tileHolder.getNextTick().c);
    }
    // *******************************************
    // *   Step five: Destroy the leftovers      *
    // *******************************************
    List<BlockPosition> deletePositions = positions;
    if (oldNativeWorld == nativeWorld)
        deletePositions = CollectionUtils.filter(positions, newPositions);
    for (int i = 0, deletePositionsSize = deletePositions.size(); i < deletePositionsSize; i++) {
        BlockPosition position = deletePositions.get(i);
        setBlockFast(oldNativeWorld, position, Blocks.AIR.getBlockData());
    }
}
Also used : BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) TileEntity(net.minecraft.server.v1_16_R3.TileEntity) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Aggregations

HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)20 Block (org.bukkit.block.Block)18 List (java.util.List)16 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)16 NotNull (org.jetbrains.annotations.NotNull)16 Chunk (org.bukkit.Chunk)14 IBlockData (net.minecraft.server.v1_14_R1.IBlockData)10 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)9 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)8 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 IBlockData (net.minecraft.server.v1_11_R1.IBlockData)7 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)7 IBlockData (net.minecraft.server.v1_8_R3.IBlockData)7 IdentityHashMap (java.util.IdentityHashMap)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)6