split chunk class into server and client
This commit is contained in:
parent
7126ca5a9f
commit
71e50743fd
35 changed files with 734 additions and 715 deletions
|
@ -19,7 +19,6 @@ import common.util.BoundingBox;
|
|||
import common.util.Facing;
|
||||
import common.util.HitPosition;
|
||||
import common.util.Vec3;
|
||||
import common.world.Chunk;
|
||||
import common.world.AWorldClient;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
@ -36,20 +35,10 @@ public class BlockTorch extends Block
|
|||
});
|
||||
|
||||
private static boolean isBlockNormalCube(World world, BlockPos pos, boolean def) {
|
||||
if(!World.isValid(pos)) {
|
||||
if(!World.isValid(pos) || (world.client && !world.isBlockLoaded(pos, false)))
|
||||
return def;
|
||||
}
|
||||
else {
|
||||
Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
||||
if(chunk.isDummy()) {
|
||||
return def;
|
||||
}
|
||||
else {
|
||||
Block block = world.getState(pos).getBlock();
|
||||
return block.getMaterial().isOpaque() && block.isFullCube();
|
||||
}
|
||||
}
|
||||
Block block = world.getState(pos).getBlock();
|
||||
return block.getMaterial().isOpaque() && block.isFullCube();
|
||||
}
|
||||
|
||||
public BlockTorch()
|
||||
|
|
|
@ -21,9 +21,6 @@ import common.util.ExtMath;
|
|||
import common.util.Vec3;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
import common.worldgen.FeatureLake;
|
||||
import common.worldgen.FeatureLiquid;
|
||||
import common.worldgen.FeatureOre;
|
||||
|
||||
public abstract class Dimension extends Nameable implements Comparable<Dimension> {
|
||||
public class GeneratorSettings {
|
||||
|
@ -288,9 +285,9 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
private Biome[] hotBiomes = null; // b.layered
|
||||
private Biome[] addBiomes = null; // b.layered
|
||||
|
||||
private final List<FeatureOre> ores = Lists.newArrayList();
|
||||
private final List<FeatureLake> lakes = Lists.newArrayList();
|
||||
private final List<FeatureLiquid> liquids = Lists.newArrayList();
|
||||
private final List<Ore> ores = Lists.newArrayList();
|
||||
private final List<Lake> lakes = Lists.newArrayList();
|
||||
private final List<Liquid> liquids = Lists.newArrayList();
|
||||
|
||||
private long seed = 0L;
|
||||
|
||||
|
@ -584,24 +581,24 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
|
||||
public final Dimension addLake(State state, State filler, State top, int chance, int minHeight, int maxHeight,
|
||||
boolean ratiod) {
|
||||
this.lakes.add(new FeatureLake(state, filler, top, chance, minHeight, maxHeight, ratiod));
|
||||
this.lakes.add(new Lake(state, filler, top, chance, minHeight, maxHeight, ratiod));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension addLiquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
|
||||
this.liquids.add(new FeatureLiquid(state, chance, minHeight, maxHeight, lower));
|
||||
this.liquids.add(new Liquid(state, chance, minHeight, maxHeight, lower));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension addOre(State state, int count, int more, int size, int minHeight, int maxHeight, boolean distrib) {
|
||||
this.ores.add(new FeatureOre(state, count, more, size, minHeight, maxHeight, distrib));
|
||||
this.ores.add(new Ore(state, count, more, size, minHeight, maxHeight, distrib));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Dimension addMetalOres(MetalType ... metals) {
|
||||
for(MetalType metal : metals) {
|
||||
int count = METAL_COUNTS[metal.rarity];
|
||||
this.ores.add(new FeatureOre(BlockRegistry.getRegisteredBlock(metal.name + "_ore").getState(),
|
||||
this.ores.add(new Ore(BlockRegistry.getRegisteredBlock(metal.name + "_ore").getState(),
|
||||
count < 0 ? 0 : count, count < 0 ? (-count) : 0, METAL_SIZES[metal.rarity], 0, METAL_HEIGHTS[metal.rarity], false));
|
||||
}
|
||||
return this;
|
||||
|
@ -1103,7 +1100,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
NBTTagList list = tag.getTagList("Ores", 10);
|
||||
for(int z = 0; z < list.tagCount(); z++) {
|
||||
NBTTagCompound gen = list.getCompoundTagAt(z);
|
||||
this.ores.add(new FeatureOre(BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
|
||||
this.ores.add(new Ore(BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
|
||||
gen.getInteger("Count"), gen.getInteger("Add"), gen.getInteger("Size"),
|
||||
gen.getInteger("MinC"), gen.getInteger("MaxS"), gen.getBoolean("Distrib")));
|
||||
}
|
||||
|
@ -1113,7 +1110,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
NBTTagList list = tag.getTagList("Lakes", 10);
|
||||
for(int z = 0; z < list.tagCount(); z++) {
|
||||
NBTTagCompound gen = list.getCompoundTagAt(z);
|
||||
this.lakes.add(new FeatureLake(
|
||||
this.lakes.add(new Lake(
|
||||
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
|
||||
gen.hasKey("Filler", 8) ? BlockRegistry.getFromIdName(gen.getString("Filler"), null) : null,
|
||||
gen.hasKey("Top", 8) ? BlockRegistry.getFromIdName(gen.getString("Top"), null) : null,
|
||||
|
@ -1125,7 +1122,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
NBTTagList list = tag.getTagList("Liquids", 10);
|
||||
for(int z = 0; z < list.tagCount(); z++) {
|
||||
NBTTagCompound gen = list.getCompoundTagAt(z);
|
||||
this.liquids.add(new FeatureLiquid(
|
||||
this.liquids.add(new Liquid(
|
||||
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
|
||||
gen.getInteger("Chance"), gen.getInteger("Min"), gen.getInteger("Max"), gen.getBoolean("Lower")));
|
||||
}
|
||||
|
@ -1294,7 +1291,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
}
|
||||
if(!this.ores.isEmpty()) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(FeatureOre gen : this.ores) {
|
||||
for(Ore gen : this.ores) {
|
||||
NBTTagCompound ore = new NBTTagCompound();
|
||||
ore.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
ore.setBoolean("Distrib", gen.dist);
|
||||
|
@ -1309,7 +1306,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
}
|
||||
if(!this.lakes.isEmpty()) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(FeatureLake gen : this.lakes) {
|
||||
for(Lake gen : this.lakes) {
|
||||
NBTTagCompound lake = new NBTTagCompound();
|
||||
lake.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
if(gen.filler != null)
|
||||
|
@ -1326,7 +1323,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
}
|
||||
if(!this.liquids.isEmpty()) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(FeatureLiquid gen : this.liquids) {
|
||||
for(Liquid gen : this.liquids) {
|
||||
NBTTagCompound liquid = new NBTTagCompound();
|
||||
liquid.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
liquid.setBoolean("Lower", gen.lower);
|
||||
|
@ -1509,15 +1506,15 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
return this.strideCaves;
|
||||
}
|
||||
|
||||
public List<FeatureOre> getOres() {
|
||||
public List<Ore> getOres() {
|
||||
return this.ores;
|
||||
}
|
||||
|
||||
public List<FeatureLake> getLakes() {
|
||||
public List<Lake> getLakes() {
|
||||
return this.lakes;
|
||||
}
|
||||
|
||||
public List<FeatureLiquid> getLiquids() {
|
||||
public List<Liquid> getLiquids() {
|
||||
return this.liquids;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package common.worldgen;
|
||||
package common.dimension;
|
||||
|
||||
import common.world.State;
|
||||
|
||||
public class FeatureLake {
|
||||
public class Lake {
|
||||
public final State state;
|
||||
public final State filler;
|
||||
public final State top;
|
||||
|
@ -11,7 +11,7 @@ public class FeatureLake {
|
|||
public final int maxHeight;
|
||||
public final boolean ratiod;
|
||||
|
||||
public FeatureLake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
|
||||
public Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
|
||||
this.state = state;
|
||||
this.filler = filler;
|
||||
this.top = top;
|
|
@ -1,15 +1,15 @@
|
|||
package common.worldgen;
|
||||
package common.dimension;
|
||||
|
||||
import common.world.State;
|
||||
|
||||
public class FeatureLiquid {
|
||||
public class Liquid {
|
||||
public final State state;
|
||||
public final int chance;
|
||||
public final int minHeight;
|
||||
public final int maxHeight;
|
||||
public final boolean lower;
|
||||
|
||||
public FeatureLiquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
|
||||
public Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
|
||||
this.state = state;
|
||||
this.chance = chance;
|
||||
this.minHeight = minHeight;
|
|
@ -1,8 +1,8 @@
|
|||
package common.worldgen;
|
||||
package common.dimension;
|
||||
|
||||
import common.world.State;
|
||||
|
||||
public class FeatureOre {
|
||||
public class Ore {
|
||||
public final State state;
|
||||
public final int count;
|
||||
public final int more;
|
||||
|
@ -11,7 +11,7 @@ public class FeatureOre {
|
|||
public final int max;
|
||||
public final boolean dist;
|
||||
|
||||
public FeatureOre(State state, int count, int more, int size, int min, int max, boolean dist) {
|
||||
public Ore(State state, int count, int more, int size, int min, int max, boolean dist) {
|
||||
this.state = state;
|
||||
this.count = count;
|
||||
this.more = more;
|
|
@ -15,7 +15,6 @@ import common.pathfinding.PathNavigateGround;
|
|||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.world.Chunk;
|
||||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
|
@ -386,8 +385,7 @@ public class EntitySlime extends EntityNPC
|
|||
public boolean getCanSpawnHere()
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(ExtMath.floord(this.posX), 0, ExtMath.floord(this.posZ));
|
||||
Chunk chunk = this.worldObj.getChunk(blockpos);
|
||||
|
||||
|
||||
// if (this.worldObj.getWorldInfo().getTerrainType() == WorldType.FLAT && this.rand.nextInt(4) != 1)
|
||||
// {
|
||||
// return false;
|
||||
|
@ -403,7 +401,7 @@ public class EntitySlime extends EntityNPC
|
|||
return super.getCanSpawnHere();
|
||||
}
|
||||
|
||||
if (this.rand.zrange(10) == 0 && getRandomWithSeed((AWorldServer)this.worldObj, chunk.xPos, chunk.zPos, 987234911L).zrange(10) == 0 && this.posY < 40.0D)
|
||||
if (this.rand.zrange(10) == 0 && getRandomWithSeed((AWorldServer)this.worldObj, blockpos.getX() >> 4, blockpos.getZ() >> 4, 987234911L).zrange(10) == 0 && this.posY < 40.0D)
|
||||
{
|
||||
return super.getCanSpawnHere();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.world.BlockArray;
|
||||
import common.world.Chunk;
|
||||
|
||||
public class SPacketChunkData implements Packet<IClientPlayer>
|
||||
{
|
||||
|
@ -22,12 +16,12 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
{
|
||||
}
|
||||
|
||||
public SPacketChunkData(Chunk chunkIn, boolean biomes, int[] extend)
|
||||
public SPacketChunkData(int x, int z, boolean biomes, SPacketChunkData.Extracted data)
|
||||
{
|
||||
this.chunkX = chunkIn.xPos;
|
||||
this.chunkZ = chunkIn.zPos;
|
||||
this.chunkX = x;
|
||||
this.chunkZ = z;
|
||||
this.biomes = biomes;
|
||||
this.extractedData = getExtractedData(chunkIn, biomes, !chunkIn.getWorld().dimension.hasNoLight(), extend);
|
||||
this.extractedData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +68,7 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
return this.extractedData.data;
|
||||
}
|
||||
|
||||
protected static int getSize(int segments, boolean overworld, boolean biomes)
|
||||
public static int getSize(int segments, boolean overworld, boolean biomes)
|
||||
{
|
||||
int i = segments * 2 * 16 * 16 * 16;
|
||||
int j = segments * 16 * 16 * 16 / 2;
|
||||
|
@ -83,72 +77,6 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
return i + j + k + l;
|
||||
}
|
||||
|
||||
public static SPacketChunkData.Extracted getExtractedData(Chunk chunk, boolean biomes, boolean overworld, int[] extend)
|
||||
{
|
||||
Set<BlockArray> aextendedblockstorage = chunk.getStorage();
|
||||
SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted();
|
||||
List<BlockArray> list = Lists.<BlockArray>newArrayList();
|
||||
|
||||
if(extend == null) {
|
||||
for(BlockArray arr : aextendedblockstorage) {
|
||||
if(arr != null && (!biomes || !arr.isEmpty()))
|
||||
list.add(arr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = chunk.getArray(cy);
|
||||
if(arr != null && (!biomes || !arr.isEmpty()))
|
||||
list.add(arr);
|
||||
}
|
||||
}
|
||||
extend = new int[list.size()];
|
||||
for(int z = 0; z < extend.length; z++) {
|
||||
extend[z] = list.get(z).getY() >> 4;
|
||||
}
|
||||
|
||||
s21packetchunkdata$extracted.extend = extend;
|
||||
s21packetchunkdata$extracted.data = new byte[getSize(extend.length, overworld, biomes)];
|
||||
int j = 0;
|
||||
|
||||
for (BlockArray extendedblockstorage1 : list)
|
||||
{
|
||||
char[] achar = extendedblockstorage1.getData();
|
||||
|
||||
for (char c0 : achar)
|
||||
{
|
||||
s21packetchunkdata$extracted.data[j++] = (byte)(c0 & 255);
|
||||
s21packetchunkdata$extracted.data[j++] = (byte)(c0 >> 8 & 255);
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockArray extendedblockstorage2 : list)
|
||||
{
|
||||
j = copyTo(extendedblockstorage2.getBlocklight().getData(), s21packetchunkdata$extracted.data, j);
|
||||
}
|
||||
|
||||
if (overworld)
|
||||
{
|
||||
for (BlockArray extendedblockstorage3 : list)
|
||||
{
|
||||
j = copyTo(extendedblockstorage3.getSkylight().getData(), s21packetchunkdata$extracted.data, j);
|
||||
}
|
||||
}
|
||||
|
||||
if (biomes)
|
||||
{
|
||||
copyTo(chunk.getBiomes(), s21packetchunkdata$extracted.data, j);
|
||||
}
|
||||
|
||||
return s21packetchunkdata$extracted;
|
||||
}
|
||||
|
||||
private static int copyTo(byte[] src, byte[] dest, int offset)
|
||||
{
|
||||
System.arraycopy(src, 0, dest, offset, src.length);
|
||||
return offset + src.length;
|
||||
}
|
||||
|
||||
public int getChunkX()
|
||||
{
|
||||
return this.chunkX;
|
||||
|
|
|
@ -1,48 +1,35 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.world.Chunk;
|
||||
|
||||
public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||
{
|
||||
private int[] xPositions;
|
||||
private int[] zPositions;
|
||||
private SPacketChunkData.Extracted[] chunksData;
|
||||
private boolean isOverworld;
|
||||
private boolean sky;
|
||||
|
||||
public SPacketMapChunkBulk()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketMapChunkBulk(List<Chunk> chunks)
|
||||
public SPacketMapChunkBulk(int[] x, int[] z, SPacketChunkData.Extracted[] chunks, boolean sky)
|
||||
{
|
||||
int i = chunks.size();
|
||||
this.xPositions = new int[i];
|
||||
this.zPositions = new int[i];
|
||||
this.chunksData = new SPacketChunkData.Extracted[i];
|
||||
this.isOverworld = !((Chunk)chunks.get(0)).getWorld().dimension.hasNoLight();
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
Chunk chunk = (Chunk)chunks.get(j);
|
||||
SPacketChunkData.Extracted s21packetchunkdata$extracted = SPacketChunkData.getExtractedData(chunk, true, this.isOverworld, null);
|
||||
this.xPositions[j] = chunk.xPos;
|
||||
this.zPositions[j] = chunk.zPos;
|
||||
this.chunksData[j] = s21packetchunkdata$extracted;
|
||||
}
|
||||
this.xPositions = x;
|
||||
this.zPositions = z;
|
||||
this.chunksData = chunks;
|
||||
this.sky = sky;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.isOverworld = buf.readBoolean();
|
||||
this.sky = buf.readBoolean();
|
||||
int i = buf.readVarIntFromBuffer();
|
||||
this.xPositions = new int[i];
|
||||
this.zPositions = new int[i];
|
||||
|
@ -57,7 +44,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
|||
for(int z = 0; z < this.chunksData[j].extend.length; z++) {
|
||||
this.chunksData[j].extend[z] = buf.readVarIntFromBuffer();
|
||||
}
|
||||
this.chunksData[j].data = new byte[SPacketChunkData.getSize(this.chunksData[j].extend.length, this.isOverworld, true)];
|
||||
this.chunksData[j].data = new byte[SPacketChunkData.getSize(this.chunksData[j].extend.length, this.sky, true)];
|
||||
}
|
||||
|
||||
for (int k = 0; k < i; ++k)
|
||||
|
@ -71,7 +58,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBoolean(this.isOverworld);
|
||||
buf.writeBoolean(this.sky);
|
||||
buf.writeVarIntToBuffer(this.chunksData.length);
|
||||
|
||||
for (int i = 0; i < this.xPositions.length; ++i)
|
||||
|
|
|
@ -8,7 +8,6 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ChunkPos;
|
||||
import common.world.Chunk;
|
||||
import common.world.State;
|
||||
|
||||
public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
||||
|
@ -16,19 +15,18 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
|||
private ChunkPos chunkPosCoord;
|
||||
private SPacketMultiBlockChange.BlockUpdateData[] changedBlocks;
|
||||
|
||||
public static BlockPos getPos(ChunkPos pos, long position)
|
||||
{
|
||||
return new BlockPos(new BlockPos((pos.x << 4) + (int)(position >> 36 & 15L), (int)(position & 4294967295L), (pos.z << 4) + (int)(position >> 32 & 15L)));
|
||||
}
|
||||
|
||||
public SPacketMultiBlockChange()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketMultiBlockChange(int p_i45181_1_, long[] crammedPositionsIn, Chunk chunkIn)
|
||||
{
|
||||
this.chunkPosCoord = new ChunkPos(chunkIn.xPos, chunkIn.zPos);
|
||||
this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[p_i45181_1_];
|
||||
|
||||
for (int i = 0; i < this.changedBlocks.length; ++i)
|
||||
{
|
||||
this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(crammedPositionsIn[i], chunkIn);
|
||||
}
|
||||
|
||||
public SPacketMultiBlockChange(ChunkPos pos, SPacketMultiBlockChange.BlockUpdateData[] changes) {
|
||||
this.chunkPosCoord = pos;
|
||||
this.changedBlocks = changes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +72,12 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
|||
return this.changedBlocks;
|
||||
}
|
||||
|
||||
public class BlockUpdateData
|
||||
public ChunkPos getChunkPos()
|
||||
{
|
||||
return this.chunkPosCoord;
|
||||
}
|
||||
|
||||
public static class BlockUpdateData
|
||||
{
|
||||
private final long position;
|
||||
private final State blockState;
|
||||
|
@ -84,19 +87,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
|||
this.position = raw;
|
||||
this.blockState = state;
|
||||
}
|
||||
|
||||
public BlockUpdateData(long raw, Chunk chunkIn)
|
||||
{
|
||||
this.position = raw;
|
||||
this.blockState = chunkIn.getState(this.getPos());
|
||||
}
|
||||
|
||||
public BlockPos getPos()
|
||||
{
|
||||
ChunkPos pos = SPacketMultiBlockChange.this.chunkPosCoord;
|
||||
return new BlockPos(new BlockPos((pos.x << 4) + (int)(this.position >> 36 & 15L), (int)(this.position & 4294967295L), (pos.z << 4) + (int)(this.position >> 32 & 15L)));
|
||||
}
|
||||
|
||||
|
||||
public long getRawPos()
|
||||
{
|
||||
return this.position;
|
||||
|
|
|
@ -3,16 +3,30 @@ package common.pathfinding;
|
|||
import common.init.Blocks;
|
||||
import common.util.BlockPos;
|
||||
import common.world.Chunk;
|
||||
import common.world.ChunkCache;
|
||||
import common.world.IBlockAccess;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class PathCache extends ChunkCache implements IBlockAccess
|
||||
public class PathCache implements IBlockAccess
|
||||
{
|
||||
public PathCache(World worldIn, BlockPos posFromIn, BlockPos posToIn)
|
||||
protected final int chunkX;
|
||||
protected final int chunkZ;
|
||||
protected final Chunk[][] data;
|
||||
|
||||
public PathCache(World world, BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
super(worldIn, posFromIn, posToIn, 0);
|
||||
this.chunkX = pos1.getX() >> 4;
|
||||
this.chunkZ = pos1.getZ() >> 4;
|
||||
int cx2 = pos2.getX() >> 4;
|
||||
int cz2 = pos2.getZ() >> 4;
|
||||
this.data = new Chunk[cx2 - this.chunkX + 1][cz2 - this.chunkZ + 1];
|
||||
for (int x = this.chunkX; x <= cx2; ++x)
|
||||
{
|
||||
for (int z = this.chunkZ; z <= cz2; ++z)
|
||||
{
|
||||
this.data[x - this.chunkX][z - this.chunkZ] = world.getChunk(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public State getState(BlockPos pos)
|
||||
|
@ -22,9 +36,9 @@ public class PathCache extends ChunkCache implements IBlockAccess
|
|||
int i = (pos.getX() >> 4) - this.chunkX;
|
||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||
|
||||
if (i >= 0 && i < this.chunkArray.length && j >= 0 && j < this.chunkArray[i].length)
|
||||
if (i >= 0 && i < this.data.length && j >= 0 && j < this.data[i].length)
|
||||
{
|
||||
Chunk chunk = this.chunkArray[i][j];
|
||||
Chunk chunk = this.data[i][j];
|
||||
|
||||
if (chunk != null)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ import common.log.Log;
|
|||
import common.nbt.NBTTagCompound;
|
||||
import common.network.Packet;
|
||||
import common.util.BlockPos;
|
||||
import common.world.AWorldServer;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -128,7 +129,8 @@ public abstract class TileEntity
|
|||
{
|
||||
State iblockstate = this.worldObj.getState(this.pos);
|
||||
this.blockMetadata = iblockstate.getBlock().getMetaFromState(iblockstate);
|
||||
this.worldObj.markChunkDirty(this.pos, this);
|
||||
if(!this.worldObj.client)
|
||||
((AWorldServer)this.worldObj).markChunkDirty(this.pos);
|
||||
|
||||
if (this.getBlockType() != Blocks.air)
|
||||
{
|
||||
|
|
|
@ -46,4 +46,5 @@ public abstract class AWorldServer extends World {
|
|||
public abstract <T extends Entity> T findNearestEntityWithinAABB(Class<? extends T> entityType, BoundingBox aabb, T closestTo);
|
||||
public abstract long getTime();
|
||||
public abstract void setBiome(BlockPos pos, Biome biome);
|
||||
public abstract void markChunkDirty(BlockPos pos);
|
||||
}
|
||||
|
|
|
@ -7,58 +7,49 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import common.biome.Biome;
|
||||
import common.block.Block;
|
||||
import common.block.ITileEntityProvider;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
import common.entity.Entity;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.log.Log;
|
||||
import common.material.Material;
|
||||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.ChunkPos;
|
||||
import common.util.ClassInheritanceMultiMap;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.util.IntHashMap;
|
||||
import common.util.NibbleArray;
|
||||
import common.worldgen.BiomeGenerator;
|
||||
import common.worldgen.DebugStates;
|
||||
|
||||
public class Chunk {
|
||||
public abstract class Chunk {
|
||||
public final int xPos;
|
||||
public final int zPos;
|
||||
private final World world;
|
||||
private final State filler;
|
||||
private final Block fillerBlock;
|
||||
private final IntHashMap<BlockArray> blocks = new IntHashMap();
|
||||
private final Set<BlockArray> blockList = Sets.newHashSet();
|
||||
private final byte[] biomes = new byte[256];
|
||||
private final int[] precHeight = new int[256];
|
||||
private final boolean[] updateSky = new boolean[256];
|
||||
private final int[] height = new int[256];
|
||||
private final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
|
||||
private final ClassInheritanceMultiMap<Entity>[] entities = new ClassInheritanceMultiMap[32];
|
||||
private final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
||||
protected final World world;
|
||||
protected final State filler;
|
||||
protected final Block fillerBlock;
|
||||
protected final IntHashMap<BlockArray> blocks = new IntHashMap();
|
||||
protected final Set<BlockArray> blockList = Sets.newHashSet();
|
||||
protected final byte[] biomes = new byte[256];
|
||||
protected final int[] precHeight = new int[256];
|
||||
protected final boolean[] updateSky = new boolean[256];
|
||||
protected final int[] height = new int[256];
|
||||
protected final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
|
||||
protected final ClassInheritanceMultiMap<Entity>[] entities = new ClassInheritanceMultiMap[32];
|
||||
protected final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
||||
|
||||
private boolean loaded;
|
||||
private boolean gapUpdate;
|
||||
private boolean populated;
|
||||
private boolean lightInit;
|
||||
private boolean updated;
|
||||
private boolean modified;
|
||||
private boolean hasEntity;
|
||||
private int minHeight;
|
||||
private int lightChecks = Integer.MAX_VALUE;
|
||||
private int bottom = Integer.MAX_VALUE;
|
||||
private int top = Integer.MIN_VALUE;
|
||||
private long lastSave;
|
||||
private long inhabited;
|
||||
protected boolean loaded;
|
||||
protected boolean gapUpdate;
|
||||
protected boolean populated;
|
||||
protected boolean lightInit;
|
||||
protected boolean updated;
|
||||
protected boolean modified;
|
||||
protected boolean hasEntity;
|
||||
protected int minHeight;
|
||||
protected int lightChecks = Integer.MAX_VALUE;
|
||||
protected int bottom = Integer.MAX_VALUE;
|
||||
protected int top = Integer.MIN_VALUE;
|
||||
|
||||
public Chunk(World world, int x, int z) {
|
||||
this.world = world;
|
||||
|
@ -72,101 +63,16 @@ public class Chunk {
|
|||
Arrays.fill(this.precHeight, -99999999);
|
||||
Arrays.fill(this.biomes, (byte)-1);
|
||||
}
|
||||
|
||||
public Chunk(World world, short[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) {
|
||||
this(world, x, z);
|
||||
boolean sky = !world.dimension.hasNoLight();
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
for(int by = 0; by < height; ++by) {
|
||||
State state = BlockRegistry.STATEMAP.getByValue(data[bx << 4 | bz | by << 8]);
|
||||
if(state != null && state.getBlock().getMaterial() != Material.air) {
|
||||
int y = by >> 4;
|
||||
BlockArray arr = this.getArray(y);
|
||||
if(arr == null) {
|
||||
arr = new BlockArray(y << 4, sky, null);
|
||||
this.setArray(arr);
|
||||
}
|
||||
arr.set(bx, by & 15, bz, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(base) {
|
||||
Block caves = world.dimension.getCaveFiller().getBlock();
|
||||
BlockArray arr = this.getArray(0);
|
||||
if(arr == null) {
|
||||
arr = new BlockArray(0, sky, null);
|
||||
this.setArray(arr);
|
||||
}
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
for(int by = 0; by < 5; ++by) {
|
||||
if(by <= rand.zrange(5)) {
|
||||
Block block = arr.get(bx, by, bz).getBlock();
|
||||
if(block == Blocks.air || block.getMaterial().isLiquid() || block == caves)
|
||||
arr.set(bx, by, bz, this.filler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ceil) {
|
||||
int y = (height - 1) >> 4;
|
||||
BlockArray arr = this.getArray(y);
|
||||
if(arr == null) {
|
||||
arr = new BlockArray(y << 4, sky, null);
|
||||
this.setArray(arr);
|
||||
}
|
||||
y = (height - 5) >> 4;
|
||||
arr = this.getArray(y);
|
||||
if(arr == null) {
|
||||
arr = new BlockArray(y << 4, sky, null);
|
||||
this.setArray(arr);
|
||||
}
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
for(int by = height - 1; by >= height - 5; --by) {
|
||||
if(by >= (height - 1) - rand.zrange(5))
|
||||
this.getArray(by >> 4).set(bx, by & 15, bz, Blocks.air.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int n = 0; n < this.biomes.length; ++n) {
|
||||
this.biomes[n] = (byte)biomes[n].id;
|
||||
}
|
||||
if(ceil)
|
||||
this.resetRelight();
|
||||
else
|
||||
this.genSkyLight();
|
||||
}
|
||||
|
||||
public int getHeight(BlockPos pos) {
|
||||
return this.getHeight(pos.getX() & 15, pos.getZ() & 15);
|
||||
}
|
||||
|
||||
|
||||
public int getHeight(int x, int z) {
|
||||
return this.height[z << 4 | x];
|
||||
}
|
||||
|
||||
public int getTopSegment() {
|
||||
return this.top;
|
||||
}
|
||||
|
||||
public int getBottomSegment() {
|
||||
return this.bottom;
|
||||
}
|
||||
|
||||
public Set<BlockArray> getStorage() {
|
||||
return this.blockList;
|
||||
}
|
||||
|
||||
public BlockArray getArray(int y) {
|
||||
return this.blocks.lookup(y);
|
||||
}
|
||||
|
||||
private void setArray(BlockArray array) {
|
||||
protected void setArray(BlockArray array) {
|
||||
int y = array.getY() >> 4;
|
||||
this.blocks.addKey(y, array);
|
||||
this.blockList.add(array);
|
||||
|
@ -174,42 +80,7 @@ public class Chunk {
|
|||
this.bottom = y < this.bottom ? y : this.bottom;
|
||||
this.top = y > this.top ? y : this.top;
|
||||
}
|
||||
|
||||
private void clearArrays() {
|
||||
this.blocks.clearMap();
|
||||
this.blockList.clear();
|
||||
this.bottom = Integer.MAX_VALUE;
|
||||
this.top = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
protected void genHeights() {
|
||||
int top = this.top;
|
||||
int bottom = this.bottom;
|
||||
this.minHeight = Integer.MAX_VALUE;
|
||||
|
||||
for(int x = 0; x < 16; ++x) {
|
||||
for(int z = 0; z < 16; ++z) {
|
||||
this.precHeight[x + (z << 4)] = -99999999;
|
||||
|
||||
for(int y = top + 16; y > bottom; --y) {
|
||||
Block block = this.getBlock0(x, y - 1, z);
|
||||
|
||||
if(block.getLightOpacity() != 0) {
|
||||
this.height[z << 4 | x] = y;
|
||||
|
||||
if(y < this.minHeight) {
|
||||
this.minHeight = y;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
|
||||
public void genSkyLight() {
|
||||
int top = this.top;
|
||||
int bottom = this.bottom;
|
||||
|
@ -415,7 +286,7 @@ public class Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
public int getOpacity(BlockPos pos) {
|
||||
private int getOpacity(BlockPos pos) {
|
||||
return this.getBlock(pos).getLightOpacity();
|
||||
}
|
||||
|
||||
|
@ -423,7 +294,7 @@ public class Chunk {
|
|||
return this.getBlock0(x, y, z).getLightOpacity();
|
||||
}
|
||||
|
||||
private Block getBlock0(int x, int y, int z) {
|
||||
protected Block getBlock0(int x, int y, int z) {
|
||||
BlockArray stor = this.getArray(y >> 4);
|
||||
return stor != null ? stor.getBlock(x, y & 15, z) : (y < 0 ? this.fillerBlock : Blocks.air);
|
||||
}
|
||||
|
@ -672,14 +543,6 @@ public class Chunk {
|
|||
return tile;
|
||||
}
|
||||
|
||||
public void addTileEntity(TileEntity tile) {
|
||||
this.addTileEntity(tile.getPos(), tile);
|
||||
|
||||
if(this.loaded) {
|
||||
this.world.addTileEntity(tile);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTileEntity(BlockPos pos, TileEntity tile) {
|
||||
tile.setWorldObj(this.world);
|
||||
tile.setPos(pos);
|
||||
|
@ -690,7 +553,7 @@ public class Chunk {
|
|||
}
|
||||
|
||||
if(tile.validate()) {
|
||||
this.setModified();
|
||||
this.modified = true;
|
||||
}
|
||||
this.tiles.put(pos, tile);
|
||||
}
|
||||
|
@ -706,19 +569,6 @@ public class Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
public void onChunkLoad() {
|
||||
this.loaded = true;
|
||||
this.world.addTileEntities(this.tiles.values());
|
||||
|
||||
for(int n = 0; n < this.entities.length; ++n) {
|
||||
for(Entity entity : this.entities[n]) {
|
||||
entity.onChunkLoad();
|
||||
}
|
||||
|
||||
this.world.loadEntities(this.entities[n]);
|
||||
}
|
||||
}
|
||||
|
||||
public void onChunkUnload() {
|
||||
this.loaded = false;
|
||||
|
||||
|
@ -731,10 +581,6 @@ public class Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
public void setModified() {
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
public void getEntities(Entity exclude, BoundingBox bb, List<Entity> list, Predicate<? super Entity> pred) {
|
||||
int sy = ExtMath.floord((bb.minY - 2.0D) / 16.0D);
|
||||
int ey = ExtMath.floord((bb.maxY + 2.0D) / 16.0D);
|
||||
|
@ -782,17 +628,6 @@ public class Chunk {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isDirty(long time) {
|
||||
if(this.hasEntity && time != this.lastSave || this.modified) {
|
||||
return true;
|
||||
}
|
||||
return this.modified;
|
||||
}
|
||||
|
||||
public boolean isDummy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public BlockPos getPrecipitation(BlockPos pos) {
|
||||
int x = pos.getX() & 15;
|
||||
int z = pos.getZ() & 15;
|
||||
|
@ -851,108 +686,6 @@ public class Chunk {
|
|||
return this.updated && this.populated && this.lightInit;
|
||||
}
|
||||
|
||||
public ChunkPos getPos() {
|
||||
return new ChunkPos(this.xPos, this.zPos);
|
||||
}
|
||||
|
||||
public boolean isEmpty(int bottom, int top) {
|
||||
for(int y = bottom; y <= top; y += 16) {
|
||||
BlockArray stor = this.getArray(y >> 4);
|
||||
|
||||
if(stor != null ? !stor.isEmpty() : (y < 0 && this.fillerBlock != Blocks.air)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setStorage(BlockArray[] data) {
|
||||
for(BlockArray arr : data) {
|
||||
this.setArray(arr);
|
||||
}
|
||||
}
|
||||
|
||||
public void setData(byte[] data, int[] extend, boolean biomes) {
|
||||
int pos = 0;
|
||||
boolean sky = !this.world.dimension.hasNoLight();
|
||||
|
||||
if(biomes) {
|
||||
this.clearArrays();
|
||||
}
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = this.getArray(cy);
|
||||
if(arr == null) {
|
||||
arr = new BlockArray(cy << 4, sky, null);
|
||||
this.setArray(arr);
|
||||
}
|
||||
|
||||
char[] blocks = arr.getData();
|
||||
|
||||
for(int k = 0; k < blocks.length; ++k) {
|
||||
blocks[k] = (char)((data[pos + 1] & 255) << 8 | data[pos] & 255);
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = this.getArray(cy);
|
||||
if(arr != null) {
|
||||
NibbleArray light = arr.getBlocklight();
|
||||
System.arraycopy(data, pos, light.getData(), 0, light.getData().length);
|
||||
pos += light.getData().length;
|
||||
}
|
||||
}
|
||||
|
||||
if(sky) {
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = this.getArray(cy);
|
||||
if(arr != null) {
|
||||
NibbleArray slight = arr.getSkylight();
|
||||
System.arraycopy(data, pos, slight.getData(), 0, slight.getData().length);
|
||||
pos += slight.getData().length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(biomes) {
|
||||
System.arraycopy(data, pos, this.biomes, 0, this.biomes.length);
|
||||
}
|
||||
|
||||
for(int cy : extend) {
|
||||
BlockArray arr = this.getArray(cy);
|
||||
if(arr != null) {
|
||||
arr.update();
|
||||
}
|
||||
}
|
||||
|
||||
this.lightInit = true;
|
||||
this.populated = true;
|
||||
this.genHeights();
|
||||
|
||||
for(TileEntity tile : this.tiles.values()) {
|
||||
tile.updateContainingBlockInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public Biome getBiome(BlockPos pos, BiomeGenerator gen) {
|
||||
int x = pos.getX() & 15;
|
||||
int z = pos.getZ() & 15;
|
||||
int o = this.biomes[z << 4 | x] & 255;
|
||||
|
||||
if(o == 255) {
|
||||
Biome biome = gen == null ? Biome.DEF_BIOME : gen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
||||
o = biome.id;
|
||||
this.biomes[z << 4 | x] = (byte)(o & 255);
|
||||
}
|
||||
|
||||
return Biome.getBiomeDef(o);
|
||||
}
|
||||
|
||||
public byte[] getBiomes() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
public void setBiomes(byte[] biomes) {
|
||||
if(this.biomes.length != biomes.length) {
|
||||
Log.JNI.warn("Konnte Biome des Chunks nicht setzen, Länge des Arrays ist " + biomes.length + " statt " + this.biomes.length);
|
||||
|
@ -1114,75 +847,12 @@ public class Chunk {
|
|||
public boolean isLoaded() {
|
||||
return this.loaded;
|
||||
}
|
||||
|
||||
public void setLoaded(boolean loaded) {
|
||||
this.loaded = loaded;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public int[] getHeights() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public void setHeights(int[] map) {
|
||||
if(this.height.length != map.length) {
|
||||
Log.JNI.warn("Konnte Höhen des Chunks nicht setzen, Länge des Arrays ist " + map.length + " statt " + this.height.length);
|
||||
}
|
||||
else {
|
||||
for(int n = 0; n < this.height.length; ++n) {
|
||||
this.height[n] = map[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<BlockPos, TileEntity> getTiles() {
|
||||
return this.tiles;
|
||||
}
|
||||
|
||||
|
||||
public ClassInheritanceMultiMap<Entity>[] getEntities() {
|
||||
return this.entities;
|
||||
}
|
||||
|
||||
public boolean isTerrainPopulated() {
|
||||
return this.populated;
|
||||
}
|
||||
|
||||
public void setTerrainPopulated(boolean populated) {
|
||||
this.populated = populated;
|
||||
}
|
||||
|
||||
public boolean isLightPopulated() {
|
||||
return this.lightInit;
|
||||
}
|
||||
|
||||
public void setLightPopulated(boolean populated) {
|
||||
this.lightInit = populated;
|
||||
}
|
||||
|
||||
public void setModified(boolean modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public void setHasEntities(boolean entities) {
|
||||
this.hasEntity = entities;
|
||||
}
|
||||
|
||||
public void setSaved(long time) {
|
||||
this.lastSave = time;
|
||||
}
|
||||
|
||||
public int getLowest() {
|
||||
return this.minHeight;
|
||||
}
|
||||
|
||||
public long getInhabited() {
|
||||
return this.inhabited;
|
||||
}
|
||||
|
||||
public void setInhabited(long time) {
|
||||
this.inhabited = time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package common.world;
|
||||
|
||||
import common.util.BlockPos;
|
||||
|
||||
public class ChunkCache
|
||||
{
|
||||
protected final int chunkX;
|
||||
protected final int chunkZ;
|
||||
protected final Chunk[][] chunkArray;
|
||||
|
||||
public ChunkCache(World worldIn, BlockPos posFromIn, BlockPos posToIn, int subIn)
|
||||
{
|
||||
this.chunkX = posFromIn.getX() - subIn >> 4;
|
||||
this.chunkZ = posFromIn.getZ() - subIn >> 4;
|
||||
int i = posToIn.getX() + subIn >> 4;
|
||||
int j = posToIn.getZ() + subIn >> 4;
|
||||
this.chunkArray = new Chunk[i - this.chunkX + 1][j - this.chunkZ + 1];
|
||||
|
||||
for (int k = this.chunkX; k <= i; ++k)
|
||||
{
|
||||
for (int l = this.chunkZ; l <= j; ++l)
|
||||
{
|
||||
this.chunkArray[k - this.chunkX][l - this.chunkZ] = worldIn.getChunk(k, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package common.worldgen;
|
||||
package common.world;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -6,7 +6,6 @@ import common.block.Block;
|
|||
import common.collect.Lists;
|
||||
import common.init.BlockRegistry;
|
||||
import common.util.ExtMath;
|
||||
import common.world.State;
|
||||
|
||||
public class DebugStates {
|
||||
private static final List<State> STATES = Lists.<State>newArrayList();
|
|
@ -133,12 +133,7 @@ public abstract class World implements IWorldAccess {
|
|||
this.gravity = Math.signum(this.gravity) * 0.075;
|
||||
}
|
||||
|
||||
public Biome getBiomeGenForCoords(final BlockPos pos) {
|
||||
if(this.isBlockLoaded(pos))
|
||||
return this.getChunk(pos).getBiome(pos, null);
|
||||
else
|
||||
return Biome.DEF_BIOME;
|
||||
}
|
||||
public abstract Biome getBiomeGenForCoords(BlockPos pos);
|
||||
|
||||
public boolean isAirBlock(BlockPos pos) {
|
||||
return this.getState(pos).getBlock().getMaterial() == Material.air;
|
||||
|
@ -191,9 +186,7 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isLoaded(int x, int z, boolean allowEmpty) {
|
||||
return allowEmpty || !this.getChunk(x, z).isDummy();
|
||||
}
|
||||
protected abstract boolean isLoaded(int x, int z, boolean allowEmpty);
|
||||
|
||||
public Chunk getChunk(BlockPos pos) {
|
||||
return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
@ -1822,12 +1815,6 @@ public abstract class World implements IWorldAccess {
|
|||
return (Entity)this.entityIds.lookup(id);
|
||||
}
|
||||
|
||||
public void markChunkDirty(BlockPos pos, TileEntity unusedTileEntity) {
|
||||
if(this.isBlockLoaded(pos)) {
|
||||
this.getChunk(pos).setModified();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadEntities(Collection<Entity> entityCollection) {
|
||||
this.entities.addAll(entityCollection);
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package common.worldgen;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import common.biome.Biome;
|
||||
import common.util.BlockPos;
|
||||
|
||||
public interface BiomeGenerator {
|
||||
public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ);
|
||||
public Biome getBiomeGenerator(BlockPos pos, Biome def);
|
||||
public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height);
|
||||
public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth);
|
||||
public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag);
|
||||
public boolean areBiomesViable(int x, int z, int size, Set<Biome> allowed);
|
||||
public void cleanupCache();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue