Search in sources :

Example 11 with World

use of net.minecraft.server.v1_7_R4.World in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_7_R4.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_7_R4.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    try {
        Field f = chunk.getClass().getDeclaredField("sections");
        f.setAccessible(true);
        ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
        ChunkSection chunksection = sections[b.getY() >> 4];
        if (chunksection == null) {
            chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
        }
        net.minecraft.server.v1_7_R4.Block mb = net.minecraft.server.v1_7_R4.Block.getById(blockId);
        chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
        chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
        if (applyPhysics) {
            w.update(b.getX(), b.getY(), b.getZ(), mb);
        }
    } catch (Exception e) {
        // Bukkit.getLogger().info("Error");
        b.setTypeIdAndData(blockId, data, applyPhysics);
    }
}
Also used : Field(java.lang.reflect.Field) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

Aggregations

World (net.minecraft.server.v1_7_R4.World)2 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)2 Field (java.lang.reflect.Field)1 World (net.minecraft.server.v1_10_R1.World)1 World (net.minecraft.server.v1_11_R1.World)1 World (net.minecraft.server.v1_12_R1.World)1 ChunkSection (net.minecraft.server.v1_7_R4.ChunkSection)1 EntityArrow (net.minecraft.server.v1_7_R4.EntityArrow)1 World (net.minecraft.server.v1_8_R1.World)1 World (net.minecraft.server.v1_8_R2.World)1 World (net.minecraft.server.v1_8_R3.World)1 World (net.minecraft.server.v1_9_R1.World)1 World (net.minecraft.server.v1_9_R2.World)1 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_8_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_8_R2.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)1