use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_7_R4 method getData.
@Override
public int getData(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_7_R4.Chunk c = (net.minecraft.server.v1_7_R4.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null)
return 0;
return sc.getData(x & 15, y & 15, z & 15);
}
use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_8_R2 method getBlock.
@Override
public Object getBlock(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_8_R2.Chunk c = (net.minecraft.server.v1_8_R2.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null)
return Blocks.AIR.getBlockData();
return sc.getType(x & 15, y & 15, z & 15);
}
use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_8_R3 method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.server.v1_8_R3.Chunk c = (net.minecraft.server.v1_8_R3.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null) {
c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
}
BlockPosition pos = new BlockPosition(x, y, z);
// REMOVE TILE ENTITY
c.tileEntities.remove(pos);
sc.setType(x & 15, y & 15, z & 15, (IBlockData) IblockData);
// ADD TILE ENTITY
if (IblockData instanceof IContainer) {
TileEntity ent = ((IContainer) IblockData).a(c.world, 0);
c.tileEntities.put(pos, ent);
Object packet = ent.getUpdatePacket();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.server.v1_12_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_9_R1 method getBlock.
@Override
public Object getBlock(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_9_R1.Chunk c = (net.minecraft.server.v1_9_R1.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null)
return Blocks.AIR.getBlockData();
return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
use of net.minecraft.server.v1_12_R1.ChunkSection in project PaperDev by Kamillaova.
the class CraftChunk method getChunkSnapshot.
public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) {
net.minecraft.server.v1_12_R1.Chunk chunk = getHandle();
ChunkSection[] cs = chunk.getSections();
short[][] sectionBlockIDs = new short[cs.length][];
byte[][] sectionBlockData = new byte[cs.length][];
byte[][] sectionSkyLights = new byte[cs.length][];
byte[][] sectionEmitLights = new byte[cs.length][];
boolean[] sectionEmpty = new boolean[cs.length];
for (int i = 0; i < cs.length; i++) {
if (cs[i] == null) {
// Section is empty?
sectionBlockIDs[i] = emptyBlockIDs;
sectionBlockData[i] = emptyData;
sectionSkyLights[i] = emptySkyLight;
sectionEmitLights[i] = emptyData;
sectionEmpty[i] = true;
} else {
// Not empty
short[] blockids = new short[4096];
byte[] rawIds = new byte[4096];
NibbleArray data = new NibbleArray();
cs[i].getBlocks().exportData(rawIds, data);
byte[] dataValues = sectionBlockData[i] = data.asBytes();
// Copy base IDs
for (int j = 0; j < 4096; j++) {
blockids[j] = (short) (rawIds[j] & 0xFF);
}
sectionBlockIDs[i] = blockids;
if (cs[i].getSkyLightArray() == null) {
sectionSkyLights[i] = emptyData;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048);
}
sectionEmitLights[i] = new byte[2048];
System.arraycopy(cs[i].getEmittedLightArray().asBytes(), 0, sectionEmitLights[i], 0, 2048);
}
}
int[] hmap = null;
if (includeMaxBlockY) {
// Get copy of height map
hmap = new int[256];
System.arraycopy(chunk.heightMap, 0, hmap, 0, 256);
}
BiomeBase[] biome = null;
double[] biomeTemp = null;
double[] biomeRain = null;
if (includeBiome || includeBiomeTempRain) {
WorldChunkManager wcm = chunk.world.getWorldChunkManager();
if (includeBiome) {
biome = new BiomeBase[256];
for (int i = 0; i < 256; i++) {
biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4), wcm);
}
}
if (includeBiomeTempRain) {
biomeTemp = new double[256];
biomeRain = new double[256];
float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4);
for (int i = 0; i < 256; i++) {
biomeTemp[i] = dat[i];
}
/* Removed 15w46a
dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16);
for (int i = 0; i < 256; i++) {
biomeRain[i] = dat[i];
}
*/
}
}
World world = getWorld();
return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionBlockData, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp, biomeRain);
}
Aggregations