use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method changeChunkServerThread.
@Override
public void changeChunkServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread != null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
resetServerThread = (Thread) chunkProviderServerThreadField.get(provider);
chunkProviderServerThreadFieldSetter.invoke(provider, Thread.currentThread());
worldThreadFieldSetter.invoke(nmsWorld, Thread.currentThread());
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method restoreServerThread.
@Override
public void restoreServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread == null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
chunkProviderServerThreadFieldSetter.invoke(provider, resetServerThread);
worldThreadFieldSetter.invoke(nmsWorld, resetServerThread);
resetServerThread = null;
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project askyblock by tastybento.
the class NMSHandler method setBlockSuperFast.
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
net.minecraft.server.v1_10_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
int combined = blockId + (data << 12);
IBlockData ibd = net.minecraft.server.v1_10_R1.Block.getByCombinedId(combined);
if (applyPhysics) {
w.setTypeAndData(bp, ibd, 3);
} else {
w.setTypeAndData(bp, ibd, 2);
}
chunk.a(bp, ibd);
}
use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project askyblock by tastybento.
the class NMSHandler method setBlockSuperFast.
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
net.minecraft.server.v1_9_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
net.minecraft.server.v1_9_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
int combined = blockId + (data << 12);
IBlockData ibd = net.minecraft.server.v1_9_R1.Block.getByCombinedId(combined);
if (applyPhysics) {
w.setTypeAndData(bp, ibd, 3);
} else {
w.setTypeAndData(bp, ibd, 2);
}
chunk.a(bp, ibd);
}
use of org.bukkit.craftbukkit.v1_15_R1.CraftWorld in project askyblock 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_R3.World w = ((CraftWorld) b.getWorld()).getHandle();
net.minecraft.server.v1_7_R3.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_R3.Block mb = net.minecraft.server.v1_7_R3.Block.e(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);
}
}
Aggregations