<commit_before>package T145.magistics.tiles;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;

public class TileElevator extends TileEntity {
	private boolean blocked = false;
	private int range = 0;
	private int count = 0;

	public boolean isBlocked() {
		return blocked;
	}

	public boolean isPowered() {
		return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
	}

	@Override
	public boolean canUpdate() {
		return true;
	}

	@Override
	public void updateEntity() {
		super.updateEntity();

		if (hasWorldObj()) {
			range = worldObj.getActualHeight() / 4;

			double xx = xCoord + 0.5;
			double yy = yCoord + 1;
			double zz = zCoord + 0.5;

			List<EntityPlayer> targets = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xx, yy, zz, xx, yy + 1, zz));

			if (targets.size() == 1) {
				EntityPlayer player = targets.get(0);
				double destY = 0;
				double endY = 0;

				++count;
				blocked = true;

				if (isPowered()) {
					endY = yy - 1;
					destY = endY - range;
				} else {
					endY = yy + 1;
					destY = range + endY;
				}

				if (count % 45 == 0) {
					count = 0;

					while (destY != endY) {
						if (isPowered()) {
							++destY;
						} else {
							--destY;
						}

						TileEntity tile = worldObj.getTileEntity(xCoord, (int) destY, zCoord);

						if (tile != null && tile instanceof TileElevator) {
							TileElevator elevator = (TileElevator) tile;

							if (!elevator.isBlocked() && !elevator.isPowered() && canTeleportTo(xCoord, (int) destY, zCoord)) {
								player.setPositionAndUpdate(player.posX, destY + 1, player.posZ);
								worldObj.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F);
								return;
							}
						}
					}
				}
			} else {
				blocked = false;
				return;
			}
		}
	}

	private boolean canTeleportTo(int x, int y, int z) {
		return canTeleportAt(x, y + 1, z) && canTeleportAt(x, y + 2, z);
	}

	private boolean canTeleportAt(int x, int y, int z) {
		Block block = worldObj.getBlock(x, y, z);

		if (block == null || block.isAir(worldObj, x, y, z)) {<commit_msg>Elevator hotfix<commit_after>package T145.magistics.tiles;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;

public class TileElevator extends TileEntity {
	private boolean blocked = false;
	private int range = 0;
	private int count = 0;

	public boolean isBlocked() {
		return blocked;
	}

	public boolean isPowered() {
		return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
	}

	@Override
	public boolean canUpdate() {
		return true;
	}

	@Override
	public void updateEntity() {
		super.updateEntity();

		if (hasWorldObj()) {
			range = worldObj.getActualHeight() / 4;

			double xx = xCoord + 0.5;
			double yy = yCoord + 1;
			double zz = zCoord + 0.5;

			List<EntityPlayer> targets = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xx, yy, zz, xx, yy + 1, zz));

			if (targets.size() == 1) {
				EntityPlayer player = targets.get(0);
				double destY = 0;
				double endY = 0;

				++count;
				blocked = true;

				if (isPowered()) {
					destY = yy - 1;
					endY = range - destY;
				} else {
					destY = yy + 1;
					endY = range + destY;
				}

				if (count % 45 == 0) {
					count = 0;

					while (destY != endY) {
						if (isPowered()) {
							--destY;
						} else {
							++destY;
						}

						TileEntity tile = worldObj.getTileEntity(xCoord, (int) destY, zCoord);
						TileElevator elevator = (TileElevator) tile;

						if (elevator != null && !elevator.isBlocked() && !elevator.isPowered() && canTeleportTo(xCoord, (int) destY, zCoord)) {
							player.setPositionAndUpdate(player.posX, destY + 1, player.posZ);
							worldObj.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F);
							return;
						}
					}
				}
			} else {
				blocked = false;
				return;
			}
		}
	}

	private boolean canTeleportTo(int x, int y, int z) {
		return canTeleportAt(x, y + 1, z) && canTeleportAt(x, y + 2, z);
	}

	private boolean canTeleportAt(int x, int y, int z) {
		Block block = worldObj.getBlock(x, y, z);

		if (block == null || block.isAir(worldObj, x, y, z)) {
{'fraction_non_alphanumeric': 0.12989364109527043, 'fraction_numerical': 0.012219959266802444, 'mean_word_length': 2.928888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4635533', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1580, 'n_words': 389}