Fixed light bug...

This commit is contained in:
makeo committed 2015-11-10 20:46:32 +01:00
1 parent 26db077d47
commit 1cc51b8a6b
4 files changed
+89 -1

No files matched your search

@@ -10,6 +10,7 @@ import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
@@ -70,6 +71,7 @@ public class ChunkProviderTCOuter implements IChunkProvider {
TCMazeHandler.GEN.chunks.remove(key);
chunk = new Chunk(worldObj, buf.blockData, buf.metaBuffer, x, z);
byte[] abyte = chunk.getBiomeArray();
System.arraycopy(biomeArr, 0, abyte, 0, biomeArr.length);
@@ -166,6 +168,18 @@ public class ChunkProviderTCOuter implements IChunkProvider {
throw new IllegalStateException("Unexpected Entity: " + bufE);
}
}
for(int cX = 0; cX < 16; cX++) {
for(int cY = 50; cY < 64; cY++) {
for(int cZ = 0; cZ < 16; cZ++) {
int lightKey = ((cX & 15) << 4 | (cZ & 15)) << 7 | cY;
int lightVal = buf.lightData[lightKey];
if(lightVal > 0) {
chunk.setLightValue(EnumSkyBlock.Block, cX, cY, cZ, lightVal);
}
}
}
}
} else {
Block[] ablock = new Block[blockArr.length];
System.arraycopy(blockArr, 0, ablock, 0, blockArr.length);
@@ -178,6 +192,7 @@ public class ChunkProviderTCOuter implements IChunkProvider {
}
chunk.generateSkylightMap();
return chunk;
}
@@ -196,6 +211,16 @@ public class ChunkProviderTCOuter implements IChunkProvider {
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.worldObj.rand, p_73153_2_, p_73153_3_, false));
net.minecraft.block.BlockFalling.fallInstantly = false;
/*for(int cX = 0; cX < 16; cX++) {
for(int cY = 50; cY < 64; cY++) {
for(int cZ = 0; cZ < 16; cZ++) {
worldObj.func_147451_t((p_73153_2_ << 4)+cX, cY, (p_73153_3_ << 4)+cZ);
}
}
}*/
}
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) {
@@ -263,6 +263,16 @@ public class TCMazeHandler {
}
MazeHandler.labyrinth = old;
for(CellLoc l : chunksAffected.keySet()) {
for(int cX = 0; cX < 16; cX++) {
for(int cY = 50; cY < 64; cY++) {
for(int cZ = 0; cZ < 16; cZ++) {
TCMazeHandler.GEN.func_147451_t((l.x << 4)+cX, cY, (l.z << 4)+cZ);
}
}
}
}
finishBuild();
}
@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.profiler.Profiler;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.MinecraftException;
@@ -28,7 +29,8 @@ import java.io.File;
public class FakeWorld extends World {
public FakeWorld(WorldProvider provider) {
super(FakeSaveHandler.instance, "", null, provider, null);
super(FakeSaveHandler.instance, "", null, provider, new Profiler());
theProfiler.profilingEnabled = false;
difficultySetting = EnumDifficulty.NORMAL;
}
@@ -5,9 +5,12 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.util.ForgeDirection;
@@ -109,6 +112,52 @@ public class FakeWorldTCGeneration extends FakeWorld {
return buf.metaBuffer[key];
}
@Override
public boolean canBlockSeeTheSky(int p_72937_1_, int p_72937_2_, int p_72937_3_) {
return false;
}
@Override
protected boolean chunkExists(int p_72916_1_, int p_72916_2_) {
return true;
}
@Override
public Chunk getChunkFromChunkCoords(int x, int z) {
long key = ((long)x) | (((long)z) << 32);
return new FakeChunk(this, x, z, chunks.get(key));
}
private static class FakeChunk extends Chunk {
private ChunkBuffer buf;
public FakeChunk(World world, int x, int z, ChunkBuffer buf) {
super(world, x, z);
this.buf = buf;
}
@Override
public void setLightValue(EnumSkyBlock type, int x, int y, int z, int light) {
if(type == EnumSkyBlock.Block) {
int key = ((x & 15) << 4 | (z & 15)) << 7 | y;
buf.lightData[key] = light;
}
}
}
@Override
public int getSavedLightValue(EnumSkyBlock type, int x, int y, int z) {
if(type == EnumSkyBlock.Block) {
ChunkBuffer buf = chunks.get(((long) x >> 4) | ((long) z >> 4) << 32);
int keyX = (x & 15) << 7 << 4;
int keyZ = (z & 15) << 7;
int key = keyX | keyZ | y;
return buf.lightData[key];
}
return 0;
}
@Override
public boolean isAirBlock(int x, int y, int z) {
return getBlock(x, y, z) == Blocks.air;
@@ -199,6 +248,7 @@ public class FakeWorldTCGeneration extends FakeWorld {
public Block[] blockData = new Block[32768];
public byte[] metaBuffer = new byte[32768];
public List<Integer[]> tiles = new ArrayList<Integer[]>();
public int[] lightData = new int[32768];
public ChunkBuffer(long key) {
this.key = key;
@@ -234,6 +284,7 @@ public class FakeWorldTCGeneration extends FakeWorld {
static {
instance = new TCFakeWorldProvider();
instance.dimensionId = ModConfig.dimOuterId;
instance.hasNoSky = true;
}
@Override