Java Code Examples for net.minecraft.util.EnumFacing#byIndex()
The following examples show how to use
net.minecraft.util.EnumFacing#byIndex() .
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: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
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); }
Example 2
Source File: BlockPosEU.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
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)); }
Example 3
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 4
Source File: BlockPassengerChair.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: TileEntityBackpack.java From WearableBackpacks with MIT License | 5 votes |
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); }
Example 6
Source File: TemplateMetadata.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
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"); }
Example 7
Source File: TargetData.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example 8
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example 9
Source File: BlockBackpack.java From WearableBackpacks with MIT License | 5 votes |
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 10
Source File: BlockVSDirectional.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 11
Source File: BlockCaptainsChair.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 12
Source File: BlockLiftLever.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 13
Source File: BlockGearbox.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 14
Source File: BlockShipHelm.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 15
Source File: BlockSpeedTelegraph.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@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); }
Example 16
Source File: ItemDolly.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
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; }
Example 17
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public EnumFacing getTemplateFacing(ItemStack stack) { NBTTagCompound tag = this.getSelectedTemplateTag(stack, Mode.PASTE, true); return EnumFacing.byIndex(tag.getByte("TemplateFacing")); }
Example 18
Source File: BlockGearbox.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public TileEntity createNewTileEntity(World worldIn, int meta) { EnumFacing facing = EnumFacing.byIndex(meta); return new TileEntityGearbox(facing); }
Example 19
Source File: BlockPosEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public BlockPosEU(BlockPos pos, int dim, int facing) { this(pos.getX(), pos.getY(), pos.getZ(), dim, EnumFacing.byIndex(facing)); }
Example 20
Source File: FluidRecipeLoader.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
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; }