<commit_before>/*
 * Source code from Tectonicus, http://code.google.com/p/tectonicus/
 *
 * Tectonicus is released under the BSD license (below).
 *
 *
 * Original code <NAME> / "<NAME>" / www.triangularpixels.com
 *
 * Copyright (c) 2012, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice, this list
 *     of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above copyright notice, this
 *     list of conditions and the following disclaimer in the documentation and/or
 *     other materials provided with the distribution.
 *   * Neither the name of 'Tecctonicus' nor the names of
 *     its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
package tectonicus.blockTypes;

import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;

import tectonicus.BlockContext;
import tectonicus.BlockType;
import tectonicus.BlockTypeRegistry;
import tectonicus.configuration.LightFace;
import tectonicus.rasteriser.Mesh;
import tectonicus.rasteriser.MeshUtil;
import tectonicus.raw.RawChunk;
import tectonicus.renderer.Geometry;
import tectonicus.texture.SubTexture;

public class Water implements BlockType
{
	private final String name;
	private SubTexture subTexture;
	
	
	public Water(String name, SubTexture subTexture)
	{
		this.name = name;
		this.subTexture = subTexture;
	}
	
	@Override
	public String getName()
	{
		return name;
	}
	
	@Override
	public boolean isSolid()
	{
		return false;
	}
	
	@Override
	public boolean isWater()
	{
		return true;
	}
	
	@Override
	public void addInteriorGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
	{
		addEdgeGeometry(x, y, z, world, registry, rawChunk, geometry);
	}
	
	@Override
	public void addEdgeGeometry(final int x, final int y, final int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
	{
		Mesh mesh = geometry.getMesh(subTexture.texture, Geometry.MeshType.Transparent);
		
		final float alpha = 0.8f;
		final float internalAlpha = 0.3f;
		final float waterLevel = 14.0f/16.0f; // This will make every water block about 2 pixels lower than a regular block.  Should this only be for surface water blocks
											  // or does it matter?
		
		final float topLight = world.getLight(rawChunk.getChunkCoord(), x, y+1, z, LightFace.Top);
		final float northLight = world.getLight(rawChunk.getChunkCoord(), x-1, y, z, LightFace.NorthSouth);
		final float southLight = world.getLight(rawChunk.getChunkCoord(), x+1, y, z, LightFace.NorthSouth);
		final float eastLight = world.getLight(rawChunk.getChunkCoord(), x, y, z-1, LightFace.EastWest);
		final float westLight = world.getLight(rawChunk.getChunkCoord(), x, y, z+1, LightFace.EastWest);
		
	//	final int northId = world.getBlockId(rawChunk.getChunkCoord(), x-1, y, z);
	//	BlockType north = registry.find(northId);
		BlockType north = world.getBlockType(rawChunk.getChunkCoord(), x-1, y, z);
		if (!north.isWater())
		{
			MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z),
									new Vector3f(x,		y+waterLevel,	z+1),
									new Vector3f(x,		y,		z+1),
									new Vector3f(x,		y,		z),
									new Vector4f(northLight, northLight, northLight, alpha),
									subTexture); 
		}
		
	//	final int southId = world.getBlockId(rawChunk.getChunkCoord(), x+1, y, z);
	//	BlockType south = registry.find(southId);
		BlockType south = world.getBlockType(rawChunk.getChunkCoord(), x+1, y, z);
		if (!south.isWater())
		{
			MeshUtil.addQuad(mesh,	new Vector3f(x+1,		y+waterLevel,		z+1),
									new Vector3f(x+1,		y+waterLevel,	z),
									new Vector3f(x+1,		y,	z),
									new Vector3f(x+1,		y,	z+1),
									new Vector4f(southLight, southLight, southLight, alpha),
									subTexture); 
		}
		
	//	final int eastId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z-1);
	//	BlockType east = registry.find(eastId);
		BlockType east = world.getBlockType(rawChunk.getChunkCoord(), x, y, z-1);
		if (!east.isWater())
		{
			MeshUtil.addQuad(mesh,	new Vector3f(x+1,	y+waterLevel,	z),
									new Vector3f(x,		y+waterLevel,	z),
									new Vector3f(x,		y,		z),
									new Vector3f(x+1,	y,		z),
									new Vector4f(eastLight, eastLight, eastLight, alpha),
									subTexture); 
		}
		
	//	final int westId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z+1);
	//	BlockType west = registry.find(westId);
		BlockType west = world.getBlockType(rawChunk.getChunkCoord(), x, y, z+1);
		if (!west.isWater())
		{
			MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z+1),
									new Vector3f(x+1,	y+waterLevel,	z+1),
									new Vector3f(x+1,	y,		z+1),
									new Vector3f(x,		y,		z+1),
									new Vector4f(westLight, westLight, westLight, alpha),
									subTexture); 
		}
		
		
	//	final int aboveId = world.getBlockId(rawChunk.getChunkCoord(), x, y+1, z);
	//	BlockType above = registry.find(aboveId);
		BlockType above = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z);
	//	if (!above.isWater())
		{
			final float aboveAlpha = above.isWater() ? internalAlpha : alpha;
			MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z),
									new Vector3f(x+1,	y+waterLevel,	z),
									new Vector3f(x+1,	y+waterLevel,	z+1),
									new Vector3f(x,		y+waterLevel,	z+1),
									new Vector4f(topLight, topLight, topLight, aboveAlpha),
									subTexture);
		}
		
	//	final int belowId = world.getBlockId(rawChunk.getChunkCoord(), x, y+1, z);
	//	BlockType below = registry.find(belowId);
		BlockType below = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z);
		if (!below.isWater())
		{
			MeshUtil.addQuad(mesh,	new Vector3f(x,		y,	z+1),
									new Vector3f(x+1,	y,	z+1),
									new Vector3f(x+1,	y,	z),
									new Vector3f(x,		y,	z),
									new Vector4f(topLight, topLight, topLight, alpha),
									subTexture);
		}
	}
	
}
<commit_msg>An attempt to get water to be more Minecraft like (needs more work)<commit_after>/*
 * Source code from Tectonicus, http://code.google.com/p/tectonicus/
 *
 * Tectonicus is released under the BSD license (below).
 *
 *
 * Original code <NAME> / "Orangy Tang" / www.triangularpixels.com
 *
 * Copyright (c) 2012, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice, this list
 *     of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above copyright notice, this
 *     list of conditions and the following disclaimer in the documentation and/or
 *     other materials provided with the distribution.
 *   * Neither the name of 'Tectonicus' nor the names of
 *     its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
package tectonicus.blockTypes;

import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;

import tectonicus.BlockContext;
import tectonicus.BlockType;
import tectonicus.BlockTypeRegistry;
import tectonicus.configuration.LightFace;
import tectonicus.rasteriser.Mesh;
import tectonicus.rasteriser.MeshUtil;
import tectonicus.raw.RawChunk;
import tectonicus.renderer.Geometry;
import tectonicus.texture.SubTexture;

public class Water implements BlockType
{
	private final String name;
	private SubTexture subTexture;
	
	
	public Water(String name, SubTexture subTexture)
	{
		this.name = name;
		this.subTexture = subTexture;
	}
	
	@Override
	public String getName()
	{
		return name;
	}
	
	@Override
	public boolean isSolid()
	{
		return false;
	}
	
	@Override
	public boolean isWater()
	{
		return true;
	}
	
	@Override
	public void addInteriorGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
	{
		addEdgeGeometry(x, y, z, world, registry, rawChunk, geometry);
	}
	
	@Override
	public void addEdgeGeometry(final int x, final int y, final int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
	{
		Mesh mesh = geometry.getMesh(subTexture.texture, Geometry.MeshType.Transparent);
		
		final float alpha = 0.8f;
		final float internalAlpha = 0.3f;
		final float waterLevel = 14.0f/16.0f;
		
		final float topLight = world.getLight(rawChunk.getChunkCoord(), x, y+1, z, LightFace.Top);
		final float northLight = world.getLight(rawChunk.getChunkCoord(), x-1, y, z, LightFace.NorthSouth);
		final float southLight = world.getLight(rawChunk.getChunkCoord(), x+1, y, z, LightFace.NorthSouth);
		final float eastLight = world.getLight(rawChunk.getChunkCoord(), x, y, z-1, LightFace.EastWest);
		final float westLight = world.getLight(rawChunk.getChunkCoord(), x, y, z+1, LightFace.EastWest);
		
		BlockType above = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z);
		BlockType aboveNorth = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z+1);
		BlockType aboveSouth = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z-1);
		BlockType aboveEast = world.getBlockType(rawChunk.getChunkCoord(), x+1, y+1, z);
		BlockType aboveWest = world.getBlockType(rawChunk.getChunkCoord(), x-1, y+1, z);
		if(!above.isWater() && !aboveNorth.isWater() && !aboveSouth.isWater() && !aboveEast.isWater() && !aboveWest.isWater())  // Only water blocks that don't have another water block above them should be lower
		{
			BlockType north = world.getBlockType(rawChunk.getChunkCoord(), x-1, y, z);
			if (!north.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z),
										new Vector3f(x,		y+waterLevel,	z+1),
										new Vector3f(x,		y,		z+1),
										new Vector3f(x,		y,		z),
										new Vector4f(northLight, northLight, northLight, alpha),
										subTexture); 
			}

			BlockType south = world.getBlockType(rawChunk.getChunkCoord(), x+1, y, z);
			if (!south.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x+1,		y+waterLevel,		z+1),
										new Vector3f(x+1,		y+waterLevel,	z),
										new Vector3f(x+1,		y,	z),
										new Vector3f(x+1,		y,	z+1),
										new Vector4f(southLight, southLight, southLight, alpha),
										subTexture); 
			}

			BlockType east = world.getBlockType(rawChunk.getChunkCoord(), x, y, z-1);
			if (!east.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x+1,	y+waterLevel,	z),
										new Vector3f(x,		y+waterLevel,	z),
										new Vector3f(x,		y,		z),
										new Vector3f(x+1,	y,		z),
										new Vector4f(eastLight, eastLight, eastLight, alpha),
										subTexture); 
			}

			BlockType west = world.getBlockType(rawChunk.getChunkCoord(), x, y, z+1);
			if (!west.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z+1),
										new Vector3f(x+1,	y+waterLevel,	z+1),
										new Vector3f(x+1,	y,		z+1),
										new Vector3f(x,		y,		z+1),
										new Vector4f(westLight, westLight, westLight, alpha),
										subTexture); 
			}
			
		//	if (!above.isWater())
			
				final float aboveAlpha = above.isWater() ? internalAlpha : alpha;
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+waterLevel,	z),
										new Vector3f(x+1,	y+waterLevel,	z),
										new Vector3f(x+1,	y+waterLevel,	z+1),
										new Vector3f(x,		y+waterLevel,	z+1),
										new Vector4f(topLight, topLight, topLight, aboveAlpha),
										subTexture);
			
			
			BlockType below = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z);
			if (!below.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y,	z+1),
										new Vector3f(x+1,	y,	z+1),
										new Vector3f(x+1,	y,	z),
										new Vector3f(x,		y,	z),
										new Vector4f(topLight, topLight, topLight, alpha),
										subTexture);
			}
		}
		else
		{
		//	final int northId = world.getBlockId(rawChunk.getChunkCoord(), x-1, y, z);
		//	BlockType north = registry.find(northId);
			BlockType north = world.getBlockType(rawChunk.getChunkCoord(), x-1, y, z);
			if (!north.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+1,	z),
										new Vector3f(x,		y+1,	z+1),
										new Vector3f(x,		y,		z+1),
										new Vector3f(x,		y,		z),
										new Vector4f(northLight, northLight, northLight, alpha),
										subTexture); 
			}
			
		//	final int southId = world.getBlockId(rawChunk.getChunkCoord(), x+1, y, z);
		//	BlockType south = registry.find(southId);
			BlockType south = world.getBlockType(rawChunk.getChunkCoord(), x+1, y, z);
			if (!south.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x+1,		y+1,		z+1),
										new Vector3f(x+1,		y+1,	z),
										new Vector3f(x+1,		y,	z),
										new Vector3f(x+1,		y,	z+1),
										new Vector4f(southLight, southLight, southLight, alpha),
										subTexture); 
			}
			
		//	final int eastId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z-1);
		//	BlockType east = registry.find(eastId);
			BlockType east = world.getBlockType(rawChunk.getChunkCoord(), x, y, z-1);
			if (!east.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x+1,	y+1,	z),
										new Vector3f(x,		y+1,	z),
										new Vector3f(x,		y,		z),
										new Vector3f(x+1,	y,		z),
										new Vector4f(eastLight, eastLight, eastLight, alpha),
										subTexture); 
			}
			
		//	final int westId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z+1);
		//	BlockType west = registry.find(westId);
			BlockType west = world.getBlockType(rawChunk.getChunkCoord(), x, y, z+1);
			if (!west.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+1,	z+1),
										new Vector3f(x+1,	y+1,	z+1),
										new Vector3f(x+1,	y,		z+1),
										new Vector3f(x,		y,		z+1),
										new Vector4f(westLight, westLight, westLight, alpha),
										subTexture); 
			}
			
			
		//	final int aboveId = world.getBlockId(rawChunk.getChunkCoord(), x, y+1, z);
		//	BlockType above = registry.find(aboveId);
			
		//	if (!above.isWater())
			
				final float aboveAlpha = above.isWater() ? internalAlpha : alpha;
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y+1,	z),
										new Vector3f(x+1,	y+1,	z),
										new Vector3f(x+1,	y+1,	z+1),
										new Vector3f(x,		y+1,	z+1),
										new Vector4f(topLight, topLight, topLight, aboveAlpha),
										subTexture);
			
			
		//	final int belowId = world.getBlockId(rawChunk.getChunkCoord(), x, y+1, z);
		//	BlockType below = registry.find(belowId);
			BlockType below = world.getBlockType(rawChunk.getChunkCoord(), x, y+1, z);
			if (!below.isWater())
			{
				MeshUtil.addQuad(mesh,	new Vector3f(x,		y,	z+1),
										new Vector3f(x+1,	y,	z+1),
										new Vector3f(x+1,	y,	z),
										new Vector3f(x,		y,	z),
										new Vector4f(topLight, topLight, topLight, alpha),
										subTexture);
			}
		}
	}
	
}

{'fraction_non_alphanumeric': 0.11902474177276003, 'fraction_numerical': 0.01525342301225078, 'mean_word_length': 3.3823684210526315, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4997265', 'n_tokens_mistral': 6952, 'n_tokens_neox': 5674, 'n_words': 1573}