Java Code Examples for net.minecraft.util.EnumFacing#DOWN
The following examples show how to use
net.minecraft.util.EnumFacing#DOWN .
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: 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 2
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public static EnumFacing getClosestLookingDirectionNotOnAxis(Entity entity, EnumFacing notOnAxis) { EnumFacing facing = getClosestLookingDirection(entity); if (facing == notOnAxis || facing.getOpposite() == notOnAxis) { if (notOnAxis == EnumFacing.UP || notOnAxis == EnumFacing.DOWN) { facing = getHorizontalLookingDirection(entity); } else { facing = getVerticalLookingDirection(entity); } } return facing; }
Example 3
Source File: BlockStairsTFC.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) { if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling) return super.doesSideBlockRendering(state, world, pos, face); if ( state.isOpaqueCube() ) return true; state = this.getActualState(state, world, pos); EnumHalf half = state.getValue(BlockStairs.HALF); EnumFacing side = state.getValue(BlockStairs.FACING); EnumShape shape = state.getValue(BlockStairs.SHAPE); if (face == EnumFacing.UP) return half == EnumHalf.TOP; if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM; if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false; if (face == side) return true; if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true; if (shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side) return true; return false; }
Example 4
Source File: BlockStairsTFC.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public boolean isSideSolid(IBlockState state,IBlockAccess world, BlockPos pos, EnumFacing side) { boolean flipped = state.getValue(BlockStairs.HALF) == EnumHalf.TOP; EnumShape shape = (EnumShape)state.getValue(BlockStairs.SHAPE); EnumFacing facing = (EnumFacing)state.getValue(BlockStairs.FACING); if (side == EnumFacing.UP) return flipped; if (side == EnumFacing.DOWN) return !flipped; if (facing == side) return true; if (flipped) { if (shape == EnumShape.INNER_LEFT) return side == facing.rotateYCCW(); if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateY(); } else { if (shape == EnumShape.INNER_LEFT) return side == facing.rotateY(); if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateYCCW(); } return false; }
Example 5
Source File: PuzzleTESR.java From YouTubeModdingTutorial with MIT License | 6 votes |
private void setupRotation(IBlockState state) { EnumFacing facing = state.getValue(BlockPuzzle.FACING); if (facing == EnumFacing.UP) { GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.translate(0.0F, 0.0F, -0.68F); } else if (facing == EnumFacing.DOWN) { GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.translate(0.0F, 0.0F, -.184F); } else { float rotY = 0.0F; if (facing == EnumFacing.NORTH) { rotY = 180.0F; } else if (facing == EnumFacing.WEST) { rotY = 90.0F; } else if (facing == EnumFacing.EAST) { rotY = -90.0F; } GlStateManager.rotate(-rotY, 0.0F, 1.0F, 0.0F); GlStateManager.translate(0.0F, -0.2500F, -0.4375F); } }
Example 6
Source File: EntityStationDeployedRocket.java From AdvancedRocketry with MIT License | 5 votes |
public EntityStationDeployedRocket(World world) { super(world); launchDirection = EnumFacing.DOWN; launchLocation = new HashedBlockPosition(0,0,0); atmText = new ModuleText(182, 114, "", 0x2d2d2d); gasId = 0; ticket = null; }
Example 7
Source File: ItemWoodSupport.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public boolean canPlaceBlockOnSide(World world, BlockPos clickedPos, EnumFacing clickedSide, EntityPlayer player, ItemStack is) { if(super.canPlaceBlockOnSide(world, clickedPos, clickedSide, player, is)) { BlockWoodSupport block = (BlockWoodSupport) this.block; IBlockState otherState = world.getBlockState(clickedPos); if(clickedSide == EnumFacing.UP || clickedSide == EnumFacing.DOWN) { return block.canBeSupportedBy(block.getDefaultState(), world.getBlockState(clickedPos)); } else { //If we are placing this block on the side of another block then it needs to be a support beam block. if(otherState.getBlock() instanceof BlockWoodSupport) { BlockWoodSupport otherBlock = (BlockWoodSupport) otherState.getBlock(); otherState = otherBlock.getActualState(otherState, world, clickedPos); if(!otherState.getValue(BlockWoodSupport.SPAN)) { return true; } } } } return false; }
Example 8
Source File: TileEntityTFOven.java From TofuCraftReload with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override @Nullable public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing) { if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (facing == EnumFacing.DOWN) return (T) handlerBottom; else if (facing == EnumFacing.UP) return (T) handlerTop; else return (T) handlerSide; return super.getCapability(capability, facing); }
Example 9
Source File: EntityUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static EnumFacing getClosestLookingDirection(Entity entity) { if (entity.rotationPitch > 60.0f) { return EnumFacing.DOWN; } else if (-entity.rotationPitch > 60.0f) { return EnumFacing.UP; } return getHorizontalLookingDirection(entity); }
Example 10
Source File: BlockNetworkRelay.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
/** * Convert the given metadata into a BlockState for this block */ @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing; switch (meta & 7) { case 0: enumfacing = EnumFacing.DOWN; break; case 1: enumfacing = EnumFacing.EAST; break; case 2: enumfacing = EnumFacing.WEST; break; case 3: enumfacing = EnumFacing.SOUTH; break; case 4: enumfacing = EnumFacing.NORTH; break; case 5: default: enumfacing = EnumFacing.UP; } return this.getDefaultState().withProperty(FACING, enumfacing); }
Example 11
Source File: TileEntityTFCompressor.java From TofuCraftReload with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override @Nullable public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing) { if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (facing == EnumFacing.DOWN) return (T) handlerBottom; else if (facing == EnumFacing.UP) return (T) handlerTop; else return (T) handlerSide; return super.getCapability(capability, facing); }
Example 12
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public static EnumFacing getVerticalLookingDirection(Entity entity) { return entity.rotationPitch > 0 ? EnumFacing.DOWN : EnumFacing.UP; }
Example 13
Source File: BlockWall.java From customstuff4 with GNU General Public License v3.0 | 4 votes |
@Override public BlockFaceShape getBlockFaceShape(IBlockAccess p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_) { return p_193383_4_ != EnumFacing.UP && p_193383_4_ != EnumFacing.DOWN ? BlockFaceShape.MIDDLE_POLE_THICK : BlockFaceShape.CENTER_BIG; }
Example 14
Source File: BlockPosEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public BlockPosEU(int x, int y, int z, int dim) { this(x, y, z, dim, EnumFacing.DOWN); }
Example 15
Source File: TileStationDeployedAssembler.java From AdvancedRocketry with MIT License | 4 votes |
public void assembleRocket() { if(bbCache == null || world.isRemote) return; //Need to scan again b/c something may have changed scanRocket(world, getPos(), bbCache); if(status != ErrorCodes.SUCCESS) return; StorageChunk storageChunk; //Breaks if nothing is there try { storageChunk = StorageChunk.cutWorldBB(world, bbCache); } catch(NegativeArraySizeException e) { return; } EntityStationDeployedRocket rocket = new EntityStationDeployedRocket(world, storageChunk, stats.copy(),bbCache.minX + (bbCache.maxX-bbCache.minX)/2f +.5f, getPos().getY() , bbCache.minZ + (bbCache.maxZ-bbCache.minZ)/2f +.5f); //TODO: setRocketDirection rocket.forwardDirection = RotatableBlock.getFront(world.getBlockState(getPos())).getOpposite(); rocket.launchDirection = EnumFacing.DOWN; //Change engine direction for(int x = 0; x < storageChunk.getSizeX(); x++) { for(int y = 0; y < storageChunk.getSizeY(); y++) { for(int z = 0; z < storageChunk.getSizeZ(); z++) { BlockPos pos3 = new BlockPos(x,y,z); if(storageChunk.getBlockState(pos3).getBlock() instanceof BlockRocketMotor ) { storageChunk.setBlockState(pos3, storageChunk.getBlockState(pos3).withProperty(BlockFullyRotatable.FACING, rocket.forwardDirection) ); } } } } world.spawnEntity(rocket); NBTTagCompound nbtdata = new NBTTagCompound(); rocket.writeToNBT(nbtdata); PacketHandler.sendToNearby(new PacketEntity((INetworkEntity)rocket, (byte)0, nbtdata), rocket.world.provider.getDimension(), this.pos, 64); stats.reset(); this.status = ErrorCodes.UNSCANNED; this.markDirty(); for(IInfrastructure infrastructure : getConnectedInfrastructure()) { rocket.linkInfrastructure(infrastructure); } }
Example 16
Source File: TileEntityTFOven.java From TofuCraftReload with MIT License | 4 votes |
/** * Returns true if automation can extract the given item in the given slot from the given side. */ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { if (direction == EnumFacing.DOWN && index == 1) return true; return false; }
Example 17
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public boolean useHoe(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { if (player.canPlayerEdit(pos, side, stack) == false) { return false; } int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, player, world, pos); if (hook != 0) { return hook > 0; } IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (side != EnumFacing.DOWN && world.isAirBlock(pos.up())) { IBlockState newBlockState = null; if (block == Blocks.GRASS) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else if (block == Blocks.DIRT) { if (state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.COARSE_DIRT) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else { return false; } } else { return false; } if (newBlockState != null) { world.setBlockState(pos, newBlockState, 3); this.addToolDamage(stack, 1, player, player); world.playSound(null, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0f, 1.0f); return true; } } return false; }
Example 18
Source File: TileEntityFuelingStation.java From AdvancedRocketry with MIT License | 4 votes |
@Override public int[] getSlotsForFace(EnumFacing side) { if(side == EnumFacing.DOWN) return new int[]{1}; return new int[]{0}; }
Example 19
Source File: BlockCartHopper.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override public int getWeakPower(IBlockState state, IBlockAccess worldIn, BlockPos pos, EnumFacing side){ if(side != EnumFacing.UP && side != EnumFacing.DOWN) return 0; TileEntityCartHopper cartHopper = (TileEntityCartHopper)worldIn.getTileEntity(pos); return cartHopper.emitsRedstone() ? 15 : 0; }
Example 20
Source File: WrapperEnumFacing.java From ClientBase with MIT License | 4 votes |
public WrapperEnumFacing getDOWN() { return new WrapperEnumFacing(EnumFacing.DOWN); }