net.minecraft.util.EnumFacing.Axis Java Examples

The following examples show how to use net.minecraft.util.EnumFacing.Axis. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GTModelWire.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
private List<BakedQuad> generateQuadsForSide(GTBlockBaseConnect wire, EnumFacing facing, int min, int max) {
	List<BakedQuad> quads = new ArrayList();
	Pair<Vector3f, Vector3f> position = this.getPosForSide(facing, min, max);
	EnumFacing[] var7 = EnumFacing.VALUES;
	int var8 = var7.length;
	for (int var9 = 0; var9 < var8; ++var9) {
		EnumFacing side = var7[var9];
		if (side.getOpposite() != facing) {
			BlockPartFace face = null;
			if (side == facing) {
				face = new BlockPartFace((EnumFacing) null, 0, "", new BlockFaceUV(new float[] { (float) min,
						(float) min, (float) max, (float) max }, 0));
			} else if (facing.getAxis() == Axis.Z && side.getAxis() == Axis.X) {
				face = new BlockPartFace((EnumFacing) null, 0, "", new BlockFaceUV(new float[] { (float) max,
						(float) min, 16.0F, (float) max }, 0));
			} else {
				face = this.getFace(facing, min, max);
			}
			// If you would like a different texture for connected sides, change the sprite
			// var to what you want
			quads.add(this.getBakery().makeBakedQuad((Vector3f) position.getKey(), (Vector3f) position.getValue(), face, wire.getTextureFromState(this.state, side), side, ModelRotation.X0_Y0, (BlockPartRotation) null, true, true));
		}
	}
	return quads;
}
 
Example #2
Source File: Canvas.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void line(Axis axis, int length) {
	int l = computeTravelDistance(length);
	boolean isPositive = length >= 0;
	for (int i = 0; i < l; i++) {
		strokeBlock();
		if (i < l - 1) {
			if (isPositive) {
				incrementAxis(axis, 1);
			} else {
				incrementAxis(axis, -1);
			}
		}

	}
}
 
Example #3
Source File: MetaTileEntityRotorHolder.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean checkTurbineFaceFree() {
    EnumFacing facing = getFrontFacing();
    boolean permuteXZ = facing.getAxis() == Axis.Z;
    BlockPos centerPos = getPos().offset(facing);
    for (int x = -1; x < 2; x++) {
        for (int y = -1; y < 2; y++) {
            BlockPos blockPos = centerPos.add(permuteXZ ? x : 0, y, permuteXZ ? 0 : x);
            IBlockState blockState = getWorld().getBlockState(blockPos);
            if (!blockState.getBlock().isAir(blockState, getWorld(), blockPos)) {
                return false;
            }
        }
    }
    return true;
}
 
Example #4
Source File: BlockCrusherBlade.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BlockCrusherBlade() {
    super(Material.IRON);
    setUnlocalizedName("gt.crusher_blade");
    setCreativeTab(GregTechAPI.TAB_GREGTECH);
    setHarvestLevel("pickaxe", 2);
    setHardness(3.0f);
    setResistance(5.0f);
    setLightOpacity(0);
    setDefaultState(getDefaultState()
        .withProperty(AXIS, Axis.Y)
        .withProperty(ACTIVE, false));
}
 
Example #5
Source File: GTModelOre.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected ModelRotation getRotation(EnumFacing facing, EnumFacing side, ModelRotation defaultRotation) {
	if (facing.getAxis().isHorizontal() && side.getAxis().isVertical()) {
		return defaultRotation;
	} else {
		return facing.getAxis().isVertical() && side.getAxis() == Axis.X ? defaultRotation : ModelRotation.X0_Y0;
	}
}
 
Example #6
Source File: GTModelBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected ModelRotation getRotation(EnumFacing facing, EnumFacing side, ModelRotation defaultRotation) {
	if (facing.getAxis().isHorizontal() && side.getAxis().isVertical()) {
		return defaultRotation;
	} else {
		return facing.getAxis().isVertical() && side.getAxis() == Axis.X ? defaultRotation : ModelRotation.X0_Y0;
	}
}
 
Example #7
Source File: BlockUtils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Set<BlockPos> blocksInSquare(BlockPos center, Axis axis, int maxBlocks, int maxRange, Predicate<BlockPos> ignore) {
	Set<BlockPos> blocks = new HashSet<>();
	if (ignore.test(center)) return blocks;
	blocks.add(center);
	if (blocks.size() >= maxBlocks) return blocks;

	Queue<BlockPos> blockQueue = new LinkedList<>();
	blockQueue.add(center);

	while (!blockQueue.isEmpty()) {
		BlockPos pos = blockQueue.remove();

		for (EnumFacing facing : EnumFacing.VALUES) {
			if (facing.getAxis() == axis)
				continue;
			BlockPos shift = pos.offset(facing);
			if (shift.getX() - center.getX() > maxRange || center.getX() - shift.getX() > maxRange)
				continue;
			if (shift.getY() - center.getY() > maxRange || center.getY() - shift.getY() > maxRange)
				continue;
			if (shift.getZ() - center.getZ() > maxRange || center.getZ() - shift.getZ() > maxRange)
				continue;
			if (blocks.contains(shift))
				continue;
			if (ignore.test(shift))
				continue;
			blocks.add(shift);
			blockQueue.add(shift);
			if (blocks.size() >= maxBlocks)
				break;
		}

		if (blocks.size() >= maxBlocks)
			break;
	}

	return blocks;
}
 
Example #8
Source File: Canvas.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void rectangle(Axis normalAxis, BlockPos pos, int width, int depth) {
	
	moveTo(pos);
	line(X, width);
	line(Z, depth);
	line(X, -width);
	line(Z, -depth);
	
	
}
 
Example #9
Source File: Canvas.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void incrementAxis(Axis axis, int amount) {
	switch (axis) {
	case X:
		x += amount;
		break;
	case Y:
		y += amount;
		break;
	case Z:
		z += amount;
		break;
	default:
		break;
	}
}
 
Example #10
Source File: BlockBackpack.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private void initBlockBounds() {
	float w = getBoundsWidth();
	float h = getBoundsHeight();
	float d = getBoundsDepth();
	for (int i = 0; i < _boundsFromFacing.length; i++) {
		EnumFacing facing = EnumFacing.byIndex(i + 2);
		_boundsFromFacing[i] = ((facing.getAxis() == Axis.Z)
			? new AxisAlignedBB(0.5F - w / 2, 0.0F, 0.5F - d / 2, 0.5F + w / 2, h, 0.5F + d / 2)
			: new AxisAlignedBB(0.5F - d / 2, 0.0F, 0.5F - w / 2, 0.5F + d / 2, h, 0.5F + w / 2));
	}
}
 
Example #11
Source File: MetaTileEntityPump.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing side) {
    return (side == null || side.getAxis() != Axis.Y) ? super.getCapability(capability, side) : null;
}
 
Example #12
Source File: BlockCrusherBlade.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta) {
    return getDefaultState()
        .withProperty(AXIS, Axis.values()[meta % 8 % 3])
        .withProperty(ACTIVE, meta / 8 > 0);
}
 
Example #13
Source File: ICanvas.java    From ToroQuest with GNU General Public License v3.0 votes vote down vote up
void line(Axis axis, int length); 
Example #14
Source File: ICanvas.java    From ToroQuest with GNU General Public License v3.0 votes vote down vote up
void rectangle(Axis normalAxis, BlockPos pos, int width, int height);