net.minecraft.util.EnumFacing#byIndex ( )源码实例Demo

下面列出了net.minecraft.util.EnumFacing#byIndex ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: enderutilities   文件: ItemBuildersWand.java
public EnumFacing getAreaFacing(ItemStack stack, Mode mode)
{
    NBTTagCompound tag = this.getSelectedTemplateTag(stack, mode, true);

    if (tag.hasKey("Rotation", Constants.NBT.TAG_BYTE))
    {
        return EnumFacing.byIndex(tag.getByte("Rotation"));
    }
    else
    {
        BlockPosEU posStart = this.getPerTemplateAreaCorner(stack, mode, true);
        BlockPosEU posEnd = this.getPerTemplateAreaCorner(stack, mode, false);

        if (posStart != null && posEnd != null)
        {
            return PositionUtils.getFacingFromPositions(posStart, posEnd);
        }
    }

    return null;
}
 
源代码2 项目: enderutilities   文件: BlockPosEU.java
public static BlockPosEU readFromTag(NBTTagCompound tag)
{
    if (tag == null ||
        tag.hasKey("posX", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("posY", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("posZ", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("dim", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("face", Constants.NBT.TAG_BYTE) == false)
    {
        return null;
    }

    int x = tag.getInteger("posX");
    int y = tag.getInteger("posY");
    int z = tag.getInteger("posZ");
    int dim = tag.getInteger("dim");
    int face = tag.getByte("face");

    return new BlockPosEU(x, y, z, dim, EnumFacing.byIndex(face));
}
 
源代码3 项目: enderutilities   文件: TileEntityEnderUtilities.java
public void readFromNBTCustom(NBTTagCompound nbt)
{
    if (nbt.hasKey("Rotation", Constants.NBT.TAG_BYTE))
    {
        this.facing = EnumFacing.byIndex(nbt.getByte("Rotation"));
    }

    /*
    if (nbt.hasKey("Camo", Constants.NBT.TAG_COMPOUND))
    {
        this.camoState = NBTUtils.readBlockStateFromTag(nbt.getCompoundTag("Camo"));
    }
    */

    if (nbt.hasKey("Camo", Constants.NBT.TAG_INT))
    {
        this.camoState = Block.getStateById(nbt.getInteger("Camo"));
    }

    if (nbt.hasKey("CamoData", Constants.NBT.TAG_COMPOUND))
    {
        this.camoData = nbt.getCompoundTag("CamoData");
    }

    this.ownerData = OwnerData.getOwnerDataFromNBT(nbt);
}
 
源代码4 项目: Valkyrien-Skies   文件: BlockPassengerChair.java
@SuppressWarnings("deprecation")
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
源代码5 项目: Valkyrien-Skies   文件: BlockSpeedTelegraph.java
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
源代码6 项目: Valkyrien-Skies   文件: BlockShipHelm.java
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
源代码7 项目: Valkyrien-Skies   文件: BlockGearbox.java
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
源代码8 项目: Valkyrien-Skies   文件: BlockLiftLever.java
@Override
@SuppressWarnings("deprecation")
@Nonnull
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
源代码9 项目: Valkyrien-Skies   文件: BlockCaptainsChair.java
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
源代码10 项目: Valkyrien-Skies   文件: BlockVSDirectional.java
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState()
        .withProperty(FACING, enumfacing);
}
 
源代码11 项目: WearableBackpacks   文件: BlockBackpack.java
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));
	}
}
 
源代码12 项目: enderutilities   文件: ItemBuildersWand.java
public EnumFacing getAreaFlipAxis(ItemStack stack, EnumFacing defaultFlipAxis)
{
    NBTTagCompound tag = this.getModeTag(stack, Mode.getMode(stack));

    if (tag.hasKey("FlipAxis", Constants.NBT.TAG_BYTE))
    {
        return EnumFacing.byIndex(tag.getByte("FlipAxis"));
    }

    return defaultFlipAxis;
}
 
源代码13 项目: enderutilities   文件: TargetData.java
public NBTTagCompound readTargetTagFromNBT(NBTTagCompound nbt)
{
    if (nbtHasTargetTag(nbt) == false)
    {
        return null;
    }

    NBTTagCompound tag = nbt.getCompoundTag("Target");
    this.pos = new BlockPos(tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ"));
    this.dimension = tag.getInteger("Dim");
    this.dimensionName = tag.getString("DimName");
    this.blockName = tag.getString("BlockName");
    this.blockMeta = tag.getByte("BlockMeta");
    this.itemMeta = tag.getByte("ItemMeta");
    this.blockFace = tag.getByte("BlockFace");
    this.facing = EnumFacing.byIndex(this.blockFace);

    this.dPosX = tag.hasKey("dPosX", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosX") : this.pos.getX() + 0.5d;
    this.dPosY = tag.hasKey("dPosY", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosY") : this.pos.getY();
    this.dPosZ = tag.hasKey("dPosZ", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosZ") : this.pos.getZ() + 0.5d;

    if (tag.hasKey("Yaw", Constants.NBT.TAG_FLOAT) && tag.hasKey("Pitch", Constants.NBT.TAG_FLOAT))
    {
        this.hasRotation = true;
        this.yaw = tag.getFloat("Yaw");
        this.pitch = tag.getFloat("Pitch");
    }

    return tag;
}
 
源代码14 项目: enderutilities   文件: TemplateMetadata.java
public void read(NBTTagCompound nbt)
{
    NBTTagList tagList = nbt.getTagList("endPosRelative", 3);
    this.endPosRelative = new BlockPos(tagList.getIntAt(0), tagList.getIntAt(1), tagList.getIntAt(2));
    this.facing = EnumFacing.byIndex(nbt.getByte("facing"));
    this.templateName = nbt.getString("name");
    this.author = nbt.getString("author");
}
 
源代码15 项目: WearableBackpacks   文件: TileEntityBackpack.java
public void readNBT(NBTTagCompound compound, boolean isClient) {
	_age = (!isClient ? compound.getInteger(TAG_AGE) : 0);
	facing = EnumFacing.byIndex(NbtUtils.get(compound, (byte)0, TAG_FACING) + 2);
	
	_stack = NbtUtils.readItem(compound.getCompoundTag(TAG_STACK));
	if (_stack.isEmpty() || isClient) { _data = null; return; }
	
	_data = BackpackHelper.getBackpackType(_stack).createBackpackData(_stack);
	NBTBase dataTag = compound.getTag(TAG_DATA);
	if (dataTag != null) _data.deserializeNBT(dataTag);
	
	_despawnTimer = (compound.hasKey(TAG_DESPAWN_TIMER)
		? compound.getInteger(TAG_DESPAWN_TIMER) : -1);
}
 
源代码16 项目: Wizardry   文件: FluidRecipeLoader.java
private static Set<BlockPos> allLiquidInPool(World world, BlockPos pos, int needed, Fluid fluid) {
	if (needed <= 0) return Sets.newHashSet();

	Block block = fluid.getBlock();
	if (block == null) return Sets.newHashSet();

	IBlockState sourceBlock = block.getDefaultState();

	BlockPos.MutableBlockPos topPos = new BlockPos.MutableBlockPos(pos);
	IBlockState stateAt = world.getBlockState(topPos);
	boolean lastWasFluid = false;
	while (stateAt.getBlock() == block) {
		lastWasFluid = stateAt == sourceBlock;
		stateAt = world.getBlockState(topPos.setPos(topPos.getX(), topPos.getY() + 1, topPos.getZ()));
	}
	topPos.setPos(topPos.getX(), topPos.getY() - 1, topPos.getZ());

	BlockPos.MutableBlockPos tool = new BlockPos.MutableBlockPos();
	Set<BlockPos> positions = Sets.newHashSet(topPos.toImmutable());

	Set<BlockPos> visited = Sets.newHashSet(positions);
	Set<BlockPos> resultants = Sets.newHashSet();
	if (lastWasFluid)
		resultants.addAll(positions);

	while (resultants.size() < needed && !positions.isEmpty() && visited.size() < 1000) {
		BlockPos point = positions.iterator().next();
		positions.remove(point);
		for (int index = EnumFacing.VALUES.length - 1; index >= 0; index--) {
			EnumFacing facing = EnumFacing.byIndex(index);
			tool.setPos(point.getX() + facing.getXOffset(),
					point.getY() + facing.getYOffset(),
					point.getZ() + facing.getZOffset());

			if (!visited.contains(tool)) {
				BlockPos immutable = tool.toImmutable();
				visited.add(immutable);
				stateAt = world.getBlockState(tool);
				if (stateAt.getBlock() == block) {
					positions.add(immutable);
					if (stateAt == sourceBlock) {
						resultants.add(immutable);

						if (resultants.size() >= needed)
							return resultants;
					}
				}
			}
		}
	}

	return resultants;
}
 
源代码17 项目: Valkyrien-Skies   文件: BlockGearbox.java
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
    EnumFacing facing = EnumFacing.byIndex(meta);
    return new TileEntityGearbox(facing);
}
 
源代码18 项目: enderutilities   文件: ItemDolly.java
private boolean tryPlaceDownBlock(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side)
{
    pos = pos.offset(side);

    if (this.isCarryingBlock(stack) == false || world.isBlockModifiable(player, pos) == false)
    {
        return false;
    }

    NBTTagCompound tagCarrying = NBTUtils.getCompoundTag(stack, "Carrying", false);
    String name = tagCarrying.getString("Block");
    int meta = tagCarrying.getByte("Meta");
    Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));

    try
    {
        if (block != null && block != Blocks.AIR && world.mayPlace(block, pos, false, side, player))
        {
            @SuppressWarnings("deprecation")
            IBlockState state = block.getStateFromMeta(meta);
            EnumFacing pickupFacing = EnumFacing.byIndex(tagCarrying.getByte("PickupFacing"));
            EnumFacing currentFacing = EntityUtils.getHorizontalLookingDirection(player);
            Rotation rotation = PositionUtils.getRotation(pickupFacing, currentFacing);
            state = state.withRotation(rotation);

            if (world.setBlockState(pos, state))
            {
                TileEntity te = world.getTileEntity(pos);

                if (te != null && tagCarrying.hasKey("te", Constants.NBT.TAG_COMPOUND))
                {
                    NBTTagCompound nbt = tagCarrying.getCompoundTag("te");
                    TileUtils.createAndAddTileEntity(world, pos, nbt, rotation, Mirror.NONE);
                }

                NBTUtils.removeCompoundTag(stack, null, "Carrying");
                return true;
            }
        }
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to place down a block from the Dolly", e);
    }

    return false;
}
 
源代码19 项目: enderutilities   文件: ItemBuildersWand.java
public EnumFacing getTemplateFacing(ItemStack stack)
{
    NBTTagCompound tag = this.getSelectedTemplateTag(stack, Mode.PASTE, true);
    return EnumFacing.byIndex(tag.getByte("TemplateFacing"));
}
 
源代码20 项目: enderutilities   文件: BlockPosEU.java
public BlockPosEU(BlockPos pos, int dim, int facing)
{
    this(pos.getX(), pos.getY(), pos.getZ(), dim, EnumFacing.byIndex(facing));
}