Java Code Examples for net.minecraft.util.EnumFacing#WEST
The following examples show how to use
net.minecraft.util.EnumFacing#WEST .
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: Scaffolder.java From EmergingTechnology with MIT License | 6 votes |
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState east = worldIn.getBlockState(pos.east()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) { face = EnumFacing.SOUTH; } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) { face = EnumFacing.NORTH; } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) { face = EnumFacing.WEST; } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) { face = EnumFacing.EAST; } worldIn.setBlockState(pos, state.withProperty(FACING, face)); } }
Example 2
Source File: Processor.java From EmergingTechnology with MIT License | 6 votes |
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState east = worldIn.getBlockState(pos.east()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) { face = EnumFacing.SOUTH; } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) { face = EnumFacing.NORTH; } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) { face = EnumFacing.WEST; } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) { face = EnumFacing.EAST; } worldIn.setBlockState(pos, state.withProperty(FACING, face)); } }
Example 3
Source File: TidalGenerator.java From EmergingTechnology with MIT License | 6 votes |
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState east = worldIn.getBlockState(pos.east()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) { face = EnumFacing.SOUTH; } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) { face = EnumFacing.NORTH; } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) { face = EnumFacing.WEST; } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) { face = EnumFacing.EAST; } worldIn.setBlockState(pos, state.withProperty(FACING, face)); } }
Example 4
Source File: Battery.java From EmergingTechnology with MIT License | 6 votes |
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState east = worldIn.getBlockState(pos.east()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) { face = EnumFacing.SOUTH; } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) { face = EnumFacing.NORTH; } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) { face = EnumFacing.WEST; } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) { face = EnumFacing.EAST; } worldIn.setBlockState(pos, state.withProperty(FACING, face)); } }
Example 5
Source File: BiomassGenerator.java From EmergingTechnology with MIT License | 6 votes |
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState east = worldIn.getBlockState(pos.east()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) { face = EnumFacing.SOUTH; } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) { face = EnumFacing.NORTH; } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) { face = EnumFacing.WEST; } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) { face = EnumFacing.EAST; } worldIn.setBlockState(pos, state.withProperty(FACING, face)); } }
Example 6
Source File: BlockTeleportRail.java From Signals with GNU General Public License v3.0 | 6 votes |
public static EnumFacing getDirection(EnumRailDirection railDir, boolean forward){ switch(railDir){ case EAST_WEST: return forward ? EnumFacing.EAST : EnumFacing.WEST; case ASCENDING_EAST: return forward ? EnumFacing.EAST : EnumFacing.WEST; case ASCENDING_WEST: return forward ? EnumFacing.WEST : EnumFacing.EAST; case NORTH_SOUTH: return forward ? EnumFacing.NORTH : EnumFacing.SOUTH; case ASCENDING_NORTH: return forward ? EnumFacing.NORTH : EnumFacing.SOUTH; case ASCENDING_SOUTH: return forward ? EnumFacing.SOUTH : EnumFacing.NORTH; default: throw new IllegalStateException("Invalid rail dir for teleport track: " + railDir); } }
Example 7
Source File: ScaffoldModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
private void placeBlock(BlockPos pos) { final Minecraft mc = Minecraft.getMinecraft(); BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}}; EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction for (int i=0; i<6; i++) { final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock(); final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) { if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) mc.player.swingArm(EnumHand.MAIN_HAND); if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } } }
Example 8
Source File: SidePicker.java From OpenModsLib with MIT License | 6 votes |
public EnumFacing toForgeDirection() { switch (this) { case XNeg: return EnumFacing.WEST; case XPos: return EnumFacing.EAST; case YNeg: return EnumFacing.DOWN; case YPos: return EnumFacing.UP; case ZNeg: return EnumFacing.NORTH; case ZPos: return EnumFacing.SOUTH; default: throw new IllegalArgumentException(toString()); } }
Example 9
Source File: AbstractRailRenderer.java From Signals with GNU General Public License v3.0 | 5 votes |
public static int getRailHeightOffset(NetworkRail<MCPos> rail, EnumFacing dir){ switch(((MCNetworkRail)rail).getCurDir()){ case ASCENDING_EAST: return dir == EnumFacing.EAST ? 1 : (dir == EnumFacing.WEST ? -1 : 0); case ASCENDING_NORTH: return dir == EnumFacing.NORTH ? 1 : (dir == EnumFacing.SOUTH ? -1 : 0); case ASCENDING_SOUTH: return dir == EnumFacing.SOUTH ? 1 : (dir == EnumFacing.NORTH ? -1 : 0); case ASCENDING_WEST: return dir == EnumFacing.WEST ? 1 : (dir == EnumFacing.EAST ? -1 : 0); default: return 0; } }
Example 10
Source File: BlockTFCompressor.java From TofuCraftReload with MIT License | 5 votes |
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } }
Example 11
Source File: IslandData.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public PortalEnumType getPortalState(EnumFacing facing) { if(facing == EnumFacing.NORTH) return northPortalState; else if(facing == EnumFacing.SOUTH) return southPortalState; else if(facing == EnumFacing.EAST) return eastPortalState; else if(facing == EnumFacing.WEST) return westPortalState; return PortalEnumType.Disabled; }
Example 12
Source File: BlockAggregator.java From TofuCraftReload with MIT License | 5 votes |
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } }
Example 13
Source File: ParticleHandlerUtil.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void addBlockHitEffects(World world, Cuboid6 bounds, EnumFacing side, TextureAtlasSprite icon, int spriteColor, ParticleManager particleManager) { float border = 0.1F; Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border); diff.x *= world.rand.nextDouble(); diff.y *= world.rand.nextDouble(); diff.z *= world.rand.nextDouble(); Vector3 pos = diff.add(bounds.min).add(border); float red = (spriteColor >> 16 & 255) / 255.0F; float green = (spriteColor >> 8 & 255) / 255.0F; float blue = (spriteColor & 255) / 255.0F; if (side == EnumFacing.DOWN) { diff.y = bounds.min.y - border; } if (side == EnumFacing.UP) { diff.y = bounds.max.y + border; } if (side == EnumFacing.NORTH) { diff.z = bounds.min.z - border; } if (side == EnumFacing.SOUTH) { diff.z = bounds.max.z + border; } if (side == EnumFacing.WEST) { diff.x = bounds.min.x - border; } if (side == EnumFacing.EAST) { diff.x = bounds.max.x + border; } DigIconParticle digIconParticle = new DigIconParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon); digIconParticle.multiplyVelocity(0.2F); digIconParticle.multipleParticleScaleBy(0.6F); digIconParticle.setRBGColorF(red, green, blue); particleManager.addEffect(digIconParticle); }
Example 14
Source File: HeadingUtils.java From Signals with GNU General Public License v3.0 | 5 votes |
public static EnumFacing toFacing(EnumHeading heading){ if(heading == null) return null; switch(heading){ case NORTH: return EnumFacing.NORTH; case SOUTH: return EnumFacing.SOUTH; case WEST: return EnumFacing.WEST; case EAST: return EnumFacing.EAST; default: throw new IllegalArgumentException(); } }
Example 15
Source File: BlockAdvancedAggregator.java From TofuCraftReload with MIT License | 5 votes |
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } }
Example 16
Source File: WorldGenFallenTree.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int num = rand.nextInt(5); EnumFacing orientation; if (num == 0) { orientation = EnumFacing.EAST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.WEST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.SOUTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } else { orientation = EnumFacing.NORTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } int i = rand.nextInt(2) + this.minTreeLength; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int j3 = 0; j3 < i; ++j3) { BlockPos offsetPos = position.offset(orientation, j3); state = worldIn.getBlockState(offsetPos); if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood); } } return true; } else { return false; } } } else { return false; } }
Example 17
Source File: WrapperEnumFacing.java From ClientBase with MIT License | 4 votes |
public WrapperEnumFacing getWEST() { return new WrapperEnumFacing(EnumFacing.WEST); }
Example 18
Source File: TileSpaceLaser.java From AdvancedRocketry with MIT License | 4 votes |
@Override public void update() { //Freaky jenky crap to make sure the multiblock loads on chunkload etc if(timeAlive == 0 && !world.isRemote) { if(isComplete()) canRender = completeStructure = completeStructure(world.getBlockState(pos)); timeAlive = 0x1; checkCanRun(); } //TODO: drain energy if(!this.world.isRemote) { tickSinceLastOperation++; if(!isAllowedToRun()) { laserSat.deactivateLaser(); this.setFinished(true); this.setRunning(false); } else if(hasPowerForOperation() && isReadyForOperation() && laserSat.isAlive() && !laserSat.getJammed()) { laserSat.performOperation(); batteries.setEnergyStored(batteries.getEnergyStored() - POWER_PER_OPERATION); tickSinceLastOperation = 0; } } if(laserSat.isFinished()) { setRunning(false); laserSat.deactivateLaser(); if(!laserSat.getJammed()) { if(mode == MODE.SINGLE) finished = true; if(this.world.getStrongPower(getPos()) != 0) { if(mode == MODE.LINE_X) { this.laserX += 3; } else if(mode == MODE.LINE_Z) { this.laserZ += 3; } else if(mode == MODE.SPIRAL) { numSteps++; if(radius < numSteps) { numSteps = 0; if(prevDir == EnumFacing.NORTH) prevDir = EnumFacing.EAST; else if(prevDir == EnumFacing.EAST){ prevDir = EnumFacing.SOUTH; radius++; } else if(prevDir == EnumFacing.SOUTH) prevDir = EnumFacing.WEST; else { prevDir = EnumFacing.NORTH; radius++; } } this.laserX += 3*prevDir.getFrontOffsetX(); this.laserZ += 3*prevDir.getFrontOffsetZ(); } } //TODO: unneeded? checkCanRun(); } } }
Example 19
Source File: ObsidianReplaceModule.java From seppuku with GNU General Public License v3.0 | 4 votes |
private EnumFacing calculateFaceForPlacement(final BlockPos structurePosition, final BlockPos blockPosition) { final BiFunction<Integer, String, Integer> throwingClamp = (number, axis) -> { if (number < -1 || number > 1) throw new IllegalArgumentException( String.format("Difference in %s is illegal, " + "positions are too far apart.", axis)); return number; }; final int diffX = throwingClamp.apply( structurePosition.getX() - blockPosition.getX(), "x-axis"); switch (diffX) { case 1: return EnumFacing.WEST; case -1: return EnumFacing.EAST; default: break; } final int diffY = throwingClamp.apply( structurePosition.getY() - blockPosition.getY(), "y-axis"); switch (diffY) { case 1: return EnumFacing.DOWN; case -1: return EnumFacing.UP; default: break; } final int diffZ = throwingClamp.apply( structurePosition.getZ() - blockPosition.getZ(), "z-axis"); switch (diffZ) { case 1: return EnumFacing.NORTH; case -1: return EnumFacing.SOUTH; default: break; } return null; }
Example 20
Source File: TileEntityBeaconLarge.java From Cyberware with MIT License | 4 votes |
@Override public void update() { IBlockState master = worldObj.getBlockState(pos.add(0, -10, 0)); boolean powered = worldObj.isBlockPowered(pos.add(1, -10, 0)) || worldObj.isBlockPowered(pos.add(-1, -10, 0)) || worldObj.isBlockPowered(pos.add(0, -10, 1)) || worldObj.isBlockPowered(pos.add(0, -10, -1)); boolean working = !powered && master.getBlock() == CyberwareContent.radioPost && master.getValue(BlockBeaconPost.TRANSFORMED) == 2; if (!wasWorking && working) { this.enable(); } if (wasWorking && !working) { disable(); } wasWorking = working; if (worldObj.isRemote && working) { count = (count + 1) % 20; if (count == 0) { IBlockState state = worldObj.getBlockState(pos); if (state.getBlock() == CyberwareContent.radioLarge) { boolean ns = state.getValue(BlockBeaconLarge.FACING) == EnumFacing.EAST || state.getValue(BlockBeaconLarge.FACING) == EnumFacing.WEST; float dist = .5F; float speedMod = .2F; int degrees = 45; for (int i = 0; i < 18; i++) { float sin = (float) Math.sin(Math.toRadians(degrees)); float cos = (float) Math.cos(Math.toRadians(degrees)); float xOffset = dist * sin; float yOffset = .2F + dist * cos; float xSpeed = speedMod * sin; float ySpeed = speedMod * cos; worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5F + (ns ? xOffset : 0), pos.getY() + .5F + yOffset, pos.getZ() + .5F + (ns ? 0 : xOffset), ns ? xSpeed : 0, ySpeed, ns ? 0 : xSpeed, new int[] {255, 255, 255}); worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5F - (ns ? xOffset : 0), pos.getY() + .5F + yOffset, pos.getZ() + .5F - (ns ? 0 : xOffset), ns ? -xSpeed : 0, ySpeed, ns ? 0 : -xSpeed, new int[] {255, 255, 255}); degrees += 5; } } } } }