<commit_before>/*
 * Copyright 2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package mapviewer.block;
import mapviewer.model.Model;
import mapviewer.model.ModelFace;
import mapviewer.world.Chunk;
import mapviewer.renderer.webgl.BlockBuilder;
import mapviewer.block.Face;

/**
 * ...
 * @author Thinkofdeath
 */
class BlockVine extends Block {
	
	static var top : Model = new Model();
	
	public static function register() {		
		top.faces.push(ModelFace.create(Face.BOTTOM, "vine", 0, 0, 16, 16, 15)
			.colour(0x87, 0xBA, 0x34));
		for (i in 0 ... 16) {
			var model = new Model();
			if (i == 0) {
				model.join(top);
			}
			if (i & 1 == 1) {
				model.faces.push(ModelFace.create(Face.BACK, "vine", 0, 0, 16, 16, 15)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.FRONT, "vine", 0, 0, 16, 16, 15)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 2 == 2) {
				model.faces.push(ModelFace.create(Face.LEFT, "vine", 0, 0, 16, 16, 1)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.RIGHT, "vine", 0, 0, 16, 16, 1)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 4 == 4) {				
				model.faces.push(ModelFace.create(Face.FRONT, "vine", 0, 0, 16, 16, 1)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.BACK, "vine", 0, 0, 16, 16, 1)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 8 == 8) {
				model.faces.push(ModelFace.create(Face.RIGHT, "vine", 0, 0, 16, 16, 15)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.LEFT, "vine", 0, 0, 16, 16, 15)
					.colour(0x87, 0xBA, 0x34));
			}
			BlockRegistry.registerBlock('vine_$i', new BlockVine().chainBlock()
				.solid(false)
				.collidable(false)
				.forceColour(true)
				.colour(0x87BA34)
				.texture("vine")
				.model(model).ret())
				.legacyId(106)
				.dataValue(i)
				.build();
		}
	}

	public function new() {
		super();
	}
	
	override public function shouldRenderAgainst(block : Block) : Bool {
		return !block.solid;
	}
	
	override public function render(builder : BlockBuilder, x : Int, y : Int, z : Int, chunk : Chunk) {
		model.render(builder, x, y, z, chunk);
		if (!shouldRenderAgainst(chunk.world.getBlock((chunk.x << 4) + x, y + 1, (chunk.z << 4) + z))) {
			top.render(builder, x, y, z, chunk);
		}
	}
	
}<commit_msg>Make vines cullable<commit_after>/*
 * Copyright 2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package mapviewer.block;
import mapviewer.model.Model;
import mapviewer.model.ModelFace;
import mapviewer.world.Chunk;
import mapviewer.renderer.webgl.BlockBuilder;
import mapviewer.block.Face;

/**
 * ...
 * @author Thinkofdeath
 */
class BlockVine extends Block {
	
	static var top : Model = new Model();
	
	public static function register() {		
		top.faces.push(ModelFace.create(Face.BOTTOM, "vine", 0, 0, 16, 16, 15.9)
			.colour(0x87, 0xBA, 0x34));
		for (i in 0 ... 16) {
			var model = new Model();
			if (i == 0) {
				model.join(top);
			}
			if (i & 1 == 1) {
				model.faces.push(ModelFace.create(Face.BACK, "vine", 0, 0, 16, 16, 15.9)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.FRONT, "vine", 0, 0, 16, 16, 15.9, true)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 2 == 2) {
				model.faces.push(ModelFace.create(Face.LEFT, "vine", 0, 0, 16, 16, 0.1)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.RIGHT, "vine", 0, 0, 16, 16, 0.1, true)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 4 == 4) {				
				model.faces.push(ModelFace.create(Face.FRONT, "vine", 0, 0, 16, 16, 0.1)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.BACK, "vine", 0, 0, 16, 16, 0.1, true)
					.colour(0x87, 0xBA, 0x34));
			}
			if (i & 8 == 8) {
				model.faces.push(ModelFace.create(Face.RIGHT, "vine", 0, 0, 16, 16, 15.9)
					.colour(0x87, 0xBA, 0x34));
				model.faces.push(ModelFace.create(Face.LEFT, "vine", 0, 0, 16, 16, 15.9, true)
					.colour(0x87, 0xBA, 0x34));
			}
			BlockRegistry.registerBlock('vine_$i', new BlockVine().chainBlock()
				.solid(false)
				.collidable(false)
				.forceColour(true)
				.colour(0x87BA34)
				.texture("vine")
				.model(model).ret())
				.legacyId(106)
				.dataValue(i)
				.build();
		}
	}

	public function new() {
		super();
	}
	
	override public function shouldRenderAgainst(block : Block) : Bool {
		return !block.solid;
	}
	
	override public function render(builder : BlockBuilder, x : Int, y : Int, z : Int, chunk : Chunk) {
		if (cachedShouldRenderAgainst == null) 
			cachedShouldRenderAgainst = shouldRenderAgainst;
		model.render(builder, x, y, z, chunk, cachedShouldRenderAgainst);
		if (!shouldRenderAgainst(chunk.world.getBlock((chunk.x << 4) + x, y + 1, (chunk.z << 4) + z))) {
			top.render(builder, x, y, z, chunk, cachedShouldRenderAgainst);
		}
	}
	
}
{'fraction_non_alphanumeric': 0.15704032809295967, 'fraction_numerical': 0.05690362269309638, 'mean_word_length': 3.2753834915997078, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '5616630', 'n_tokens_mistral': 2720, 'n_tokens_neox': 2132, 'n_words': 583}