package zmaster587.advancedRocketry.world.util;

import zmaster587.advancedRocketry.util.StorageChunk;
import net.minecraft.block.Block;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.entity.Entity;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.util.ForgeDirection;

public class WorldDummy extends World {

	private final static ProviderDummy dummyProvider = new ProviderDummy();

	StorageChunk storage;

	public WorldDummy(Profiler p_i45368_5_, StorageChunk storage) {
		super(new DummySaveHandler(), "dummy", new WorldSettings(0, WorldSettings.GameType.SURVIVAL, false, false, WorldType.FLAT), dummyProvider, p_i45368_5_);
		this.storage = storage;
	}

	@Override
	public Block getBlock(int x, int y, int z) {
		return storage.getBlock(x, y, z);
	}

	@Override
	public int getBlockLightOpacity(int x, int y, int z) {
		return getBlock(x, y, z).getLightOpacity();
	}

	@Override
	public int getBlockMetadata(int x, int y, int z) {
		return storage.getBlockMetadata(x, y, z);
	}

	@Override
	public TileEntity getTileEntity(int x, int y, int z) {
		return storage.getTileEntity(x, y, z);
	}

	@Override
	public boolean isSideSolid(int x, int y, int z, ForgeDirection side,
			boolean _default) {
		return storage.isSideSolid(x, y, z, side, _default);
	}

	@Override
	public void notifyBlockOfNeighborChange(int p_147460_1_, int p_147460_2_, int p_147460_3_, final Block p_147460_4_) {

		//Dummy out

	}


	@Override
	protected boolean chunkExists(int x, int z) {
		return false;
	}

	@Override
    public boolean blockExists(int p_72899_1_, int p_72899_2_, int p_72899_3_) {
    	return false;
    }
	
	@Override
	public int getBlockLightValue_do(int p_72849_1_, int p_72849_2_,
			int p_72849_3_, boolean p_72849_4_) {

		if (p_72849_4_ && this.getBlock(p_72849_1_, p_72849_2_, p_72849_3_).getUseNeighborBrightness())
		{
			return super.getBlockLightValue_do(p_72849_1_, p_72849_2_, p_72849_3_,
					p_72849_4_);
		}
		else 
			return 15;//TODO: make chunks
	}

	@Override
	protected void finishSetup() {
		//Dont care about villages or providers or registration here
		this.chunkProvider = this.createChunkProvider();
	}

	@Override
	protected void func_147467_a(int p_147467_1_, int p_147467_2_,
			Chunk p_147467_3_) {
		// Dummy out
	}

	@Override
	protected void setActivePlayerChunksAndCheckLight() {
		//dummy out
	}

	@Override
	public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_) {
		return false;
		//Dummy out
	}
	
	@Override
	public boolean setBlockMetadataWithNotify(int p_72921_1_, int p_72921_2_, int p_72921_3_, int p_72921_4_, int p_72921_5_) {
		return false;
		//Dummy it out
	}

	@Override
	public void updateEntities() {
		//Dummy out
	}

	@Override
	public void tick() {
		//Dont tick
	}

	@Override
	public boolean tickUpdates(boolean p_72955_1_) {
		//Dont tick
		return false;
	}

	@Override
	protected IChunkProvider createChunkProvider() {
		// TODO Auto-generated method stub
		return new ChunkProviderClient(this);
	}

	@Override
	protected int func_152379_p() {
		return 0;
	}

	//No entities exist
	@Override
	public Entity getEntityByID(int p_73045_1_) {
		return null;
	}

}

@@ -3255,43 +3255,27 @@
 %7B%0A%09%09
-// TODO Auto-generated method stub%0A
+if(this.isRemote)%0A%09
 %09%09re
@@ -3310,16 +3310,40 @@
 (this);%0A
+%09%09else %0A%09%09%09return null;%0A
 %09%7D%0A%0A%09@Ov

Fix invalid side exception in stable branch