Java Code Examples for net.minecraft.util.EnumFacing#ordinal()

The following examples show how to use net.minecraft.util.EnumFacing#ordinal() . 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: RenderCrop.java    From AgriCraft with MIT License 6 votes vote down vote up
private void renderBaseQuads(ITessellator tessellator, EnumFacing side, TextureAtlasSprite sprite) {
    int index = side == null ? EnumFacing.values().length : side.ordinal();
    boolean createQuads = false;
    if (!cropQuads.containsKey(tessellator.getVertexFormat())) {
        List<BakedQuad>[] lists = new List[EnumFacing.values().length + 1];
        cropQuads.put(tessellator.getVertexFormat(), lists);
        createQuads = true;
    } else if (cropQuads.get(tessellator.getVertexFormat())[index] == null) {
        createQuads = true;
    }
    if (createQuads) {
        tessellator.translate(0, -3 * Constants.UNIT, 0);
        tessellator.drawScaledPrism(2, 0, 2, 3, 16, 3, sprite);
        tessellator.drawScaledPrism(13, 0, 2, 14, 16, 3, sprite);
        tessellator.drawScaledPrism(13, 0, 13, 14, 16, 14, sprite);
        tessellator.drawScaledPrism(2, 0, 13, 3, 16, 14, sprite);
        tessellator.translate(0, 3 * Constants.UNIT, 0);
    } else {
        tessellator.addQuads(cropQuads.get(tessellator.getVertexFormat())[index]);
    }
}
 
Example 2
Source File: TilePipe.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
protected void attemptLink(EnumFacing dir, TileEntity tile) {
	//If the pipe can inject or extract, add to the cache
	//if(!(tile instanceof IFluidHandler))
	//return;

	if(canExtract(dir, tile) && (world.isBlockIndirectlyGettingPowered(pos) > 0 || world.getStrongPower(pos) > 0)) {
		if(world.isRemote)
			connectedSides[dir.ordinal()]=true;
		else {
			getNetworkHandler().removeFromAllTypes(this, tile);
			getNetworkHandler().addSource(this,tile,dir);
			connectedSides[dir.ordinal()]=true;
		}
	}

	if(canInject(dir, tile) && world.isBlockIndirectlyGettingPowered(pos) == 0 && world.getStrongPower(pos) == 0) {
		if(world.isRemote)
			connectedSides[dir.ordinal()]=true;
		else {
			getNetworkHandler().removeFromAllTypes(this, tile);
			getNetworkHandler().addSink(this, tile,dir);
			connectedSides[dir.ordinal()]=true;
		}
	}
}
 
Example 3
Source File: TileEnergyPipe.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
protected void attemptLink(EnumFacing dir, TileEntity tile) {
	//If the pipe can inject or extract, add to the cache
	//if(!(tile instanceof IFluidHandler))
	//return;
	//if(world.isRemote && tile instanceof TileEnergyPipe)
	//	connectedSides[dir.ordinal()]=true;

	if(canExtract(dir, tile)) {
		if(!world.isRemote) {
			connectedSides[dir.ordinal()]=true;
			getNetworkHandler().removeFromAllTypes(this, tile);
			getNetworkHandler().addSource(this,tile,dir);
		}
	}

	if(canInject(dir, tile)) {
		if(!world.isRemote) {
			connectedSides[dir.ordinal()]=true;
			getNetworkHandler().removeFromAllTypes(this, tile);
			getNetworkHandler().addSink(this, tile,dir);
		}
	}
}
 
Example 4
Source File: ImplRotationNode.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@PhysicsThreadOnly
@Override
public Optional<Double> getAngularVelocityRatioFor(EnumFacing side) {
    PhysicsAssert.assertPhysicsThread();
    assertInitialized();
    return angularVelocityRatios[side.ordinal()];
}
 
Example 5
Source File: ItemUpgradeDirectional.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setSide(ItemStack stack, EnumFacing side) {
	NBTTagCompound nbt = stack.getTagCompound();
	if (nbt == null) {
		stack.setTagCompound(nbt = new NBTTagCompound());
	}

	int target = -1;
	if (side != null) {
		target = side.ordinal();
	}
	nbt.setInteger("dir", target);
}
 
Example 6
Source File: BlockBackpack.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	TileEntity entity = source.getTileEntity(pos);
	EnumFacing facing = (entity instanceof TileEntityBackpack)
		? ((TileEntityBackpack)entity).facing
		: EnumFacing.NORTH;
	return _boundsFromFacing[facing.ordinal() - 2];
}
 
Example 7
Source File: BlockMetalPlate.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
   public void addCollisionBoxToList(final IBlockState bs, final World world, final BlockPos coord,
                                       final AxisAlignedBB box, final List<AxisAlignedBB> collisionBoxList,
                                       final Entity entity) {

       final EnumFacing orientation = (EnumFacing) world.getBlockState(coord).getValue(FACING);
       super.addCollisionBoxToList(coord, box, collisionBoxList, BOXES[orientation.ordinal()]);
}
 
Example 8
Source File: TilePipe.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void onPlaced() {

		for(EnumFacing dir : EnumFacing.values()) {
			TileEntity tile = world.getTileEntity(getPos().offset(dir));


			if(tile != null) {
				if(tile instanceof TilePipe && tile.getClass() == this.getClass()) {
					TilePipe pipe = (TilePipe)tile;
					if(this.destroyed)
						continue;

					if(isInitialized() && pipe.isInitialized() && pipe.getNetworkID() != networkID)
						getNetworkHandler().mergeNetworks(networkID,  pipe.getNetworkID());
					else if(!isInitialized() && pipe.isInitialized()) {
						initialize(pipe.getNetworkID());
					}
					connectedSides[dir.ordinal()] = true;
				}
			}
		}


		if(!isInitialized()) {
			initialize(getNetworkHandler().getNewNetworkID());
		}

		linkSystems();
	}
 
Example 9
Source File: TileEntityGearbox.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void update() {
    super.update();
    if (!this.getWorld().isRemote) {
        Optional<Double>[] rotationNodeRatios = this.rotationNode
            .connectedRotationRatiosUnsychronized();
        for (EnumFacing facing : EnumFacing.values()) {
            if (!this.rotationNode.isConnectedToSideUnsynchronized(facing)) {
                rotationNodeRatios[facing.ordinal()] = Optional.empty();
            }
        }
        connectedSidesRatios = rotationNodeRatios;
    }
    this.markDirty();
}
 
Example 10
Source File: ImplRotationNode.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@PhysicsThreadOnly
@Override
public void setAngularVelocityRatio(EnumFacing side, Optional<Double> newRatio) {
    PhysicsAssert.assertPhysicsThread();
    assertInitialized();
    angularVelocityRatios[side.ordinal()] = newRatio;
}
 
Example 11
Source File: EasyPlaceUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Vec3d applyCarpetProtocolHitVec(BlockPos pos, IBlockState state, Vec3d hitVecIn)
{
    double x = hitVecIn.x;
    double y = hitVecIn.y;
    double z = hitVecIn.z;
    Block block = state.getBlock();
    EnumFacing facing = fi.dy.masa.malilib.util.BlockUtils.getFirstPropertyFacingValue(state);

    if (facing != null)
    {
        x = facing.ordinal() + 2 + pos.getX();
    }

    if (block instanceof BlockRedstoneRepeater)
    {
        x += ((state.getValue(BlockRedstoneRepeater.DELAY)) - 1) * 10;
    }
    else if (block instanceof BlockTrapDoor && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.TOP)
    {
        x += 10;
    }
    else if (block instanceof BlockRedstoneComparator && state.getValue(BlockRedstoneComparator.MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
    {
        x += 10;
    }
    else if (block instanceof BlockStairs && state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP)
    {
        x += 10;
    }

    return new Vec3d(x, y, z);
}
 
Example 12
Source File: FWItemBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
	return ItemWrapperMethods.super.onItemUse(itemStack, player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
 
Example 13
Source File: FWItem.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
	return ItemWrapperMethods.super.onItemUse(itemStack, player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
 
Example 14
Source File: FWItemBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
 
Example 15
Source File: FWItem.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
 
Example 16
Source File: BlockMetalPlate.java    From BaseMetals with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(final IBlockState bs, final IBlockAccess world, final BlockPos coord) {
    final EnumFacing orientation = (EnumFacing) bs.getValue(FACING);
    return BOXES[orientation.ordinal()];
}
 
Example 17
Source File: ImplRotationNode.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<Double> getAngularVelocityRatioForUnsynchronized(EnumFacing side) {
    assertInitialized();
    return angularVelocityRatios[side.ordinal()];
}