net.minecraft.util.EnumFacing Java Examples
The following examples show how to use
net.minecraft.util.EnumFacing.
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: WorldGeneratorSignals.java From Signals with GNU General Public License v3.0 | 6 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){ // TODO when adding worldgen, resolve the note at https://github.com/MineMaarten/Signals/pull/80 regarding the possibility of rails not being included in the network. if(chunkX == 0) { int x = chunkX * 16 + 8; int y = 4; int startZ = chunkZ * 16; for(int z = startZ; z < startZ + 16; z++) { world.setBlockState(new BlockPos(x, y, z), Blocks.STONE.getDefaultState(), 0); world.setBlockState(new BlockPos(x, y + 1, z), Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, EnumRailDirection.NORTH_SOUTH), 0); if(z % 256 == 0) { world.setBlockState(new BlockPos(x + 1, y + 1, z), ModBlocks.BLOCK_SIGNAL.getDefaultState().withProperty(BlockSignalBase.FACING, EnumFacing.NORTH), 0); } } } }
Example #2
Source File: EvalModelTest.java From OpenModsLib with MIT License | 6 votes |
@Test public void testArithmeticsVarApply() { EvaluatorFactory factory = new EvaluatorFactory(); factory.appendStatement("clip(2.4 / a + 1/(3 * b))"); final ClipStub clipStub = new ClipStub(); final IJointClip jointClipMock = clipStub.jointClipMock; final TRSRTransformation transform = TRSRTransformation.from(EnumFacing.NORTH); Mockito.when(jointClipMock.apply(Matchers.anyFloat())).thenReturn(transform); final TRSRTransformation result = factory.createEvaluator(clips("clip", clipStub)) .evaluate(DUMMY_JOINT, ImmutableMap.of("a", 5.1f, "b", -0.4f)); Assert.assertEquals(transform, result); Mockito.verify(jointClipMock).apply(2.4f / 5.1f + 1f / (3f * -0.4f)); Mockito.verifyNoMoreInteractions(jointClipMock); }
Example #3
Source File: StructureTofuVillagePieces.java From TofuCraftReload with MIT License | 6 votes |
@SuppressWarnings("deprecation") public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { if (this.averageGroundLvl < 0) { this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn); if (this.averageGroundLvl < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 5, 0); } IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.SPRUCE_FENCE.getDefaultState()); this.setBlockState(worldIn, iblockstate, 1, 0, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 2, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.WOOL.getStateFromMeta(EnumDyeColor.BLACK.getDyeDamage()), 1, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.EAST, 2, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.NORTH, 1, 3, 1, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.WEST, 0, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.SOUTH, 1, 3, -1, structureBoundingBoxIn); return true; }
Example #4
Source File: HarvesterTileEntity.java From EmergingTechnology with MIT License | 6 votes |
public boolean canHarvest(EnumFacing facing) { if (getTargetBlockState(facing) == null) { } if (!sufficientEnergy()) { return false; } if (outputsFull()) { return false; } if (HarvesterHelper.isInteractableCrop(getTargetBlockState(facing).getBlock())) { return HarvesterHelper.isInteractableCropReadyForHarvest(getTargetBlockState(facing), getWorld(), getTarget(facing)); } return PlantHelper.isCropAtPositionReadyForHarvest(getWorld(), getTarget(facing)); }
Example #5
Source File: BlockPackager.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
public EnumFacing getFacingFromMeta(int meta) { if (meta == 0) { return EnumFacing.EAST; } if (meta == 1) { return EnumFacing.WEST; } if (meta == 2) { return EnumFacing.NORTH; } if (meta == 3) { return EnumFacing.SOUTH; } if (meta == 4) { return EnumFacing.UP; } if (meta == 5) { return EnumFacing.DOWN; } return EnumFacing.EAST; }
Example #6
Source File: BlockManipulator.java From OpenModsLib with MIT License | 6 votes |
public boolean place(IBlockState state, EnumFacing direction, EnumHand hand) { if (!world.isBlockLoaded(blockPos)) return false; if (spawnProtection) { if (!world.isBlockModifiable(player, blockPos)) return false; } final BlockSnapshot snapshot = BlockSnapshot.getBlockSnapshot(world, blockPos); if (!world.setBlockState(blockPos, state, blockPlaceFlags)) return false; if (ForgeEventFactory.onPlayerBlockPlace(player, snapshot, direction, hand).isCanceled()) { world.restoringBlockSnapshots = true; snapshot.restore(true, false); world.restoringBlockSnapshots = false; return false; } return true; }
Example #7
Source File: BlockTorchUnlit.java From AdvancedRocketry with MIT License | 6 votes |
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(player.getHeldItem(EnumHand.MAIN_HAND) != null) { Item item = player.getHeldItem(EnumHand.MAIN_HAND).getItem(); if(!world.isRemote && item != null && AtmosphereHandler.getOxygenHandler(world.provider.getDimension()).getAtmosphereType(pos).allowsCombustion() && (item == Item.getItemFromBlock(Blocks.TORCH) || item == Items.FLINT_AND_STEEL || item == Items.FIRE_CHARGE)) { world.setBlockState(pos, Blocks.TORCH.getDefaultState().withProperty(FACING, state.getValue(FACING))); return true; } } return true; }
Example #8
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock(); TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos); if (tileEntity == null) { return; } InventoryPipeType pipeType = tileEntity.getPipeType(); if (pipeType == null) { return; } float thickness = pipeType.getThickness(); int connectedSidesMask = block.getActualConnections(tileEntity, world); Cuboid6 baseBox = BlockPipe.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockPipe.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example #9
Source File: NetworkSimplifier.java From Logistics-Pipes-2 with MIT License | 6 votes |
private WeightedNetworkNode createWeightedNode(NetworkNode node, Map<UUID, WeightedNetworkNode> results, Map<UUID, Tuple<NetworkNode, EnumFacing>> destinations) { if (results.containsKey(node.getId())) return results.get(node.getId()); WeightedNetworkNode current = new WeightedNetworkNode(node.getId(), node.getMember()); for (int i = 0; i < 6; i++) { current.addNeighbor(node.getNeighborAt(i), i); } //current.getMember().spawnParticle(1.0f, 1.0f, 0.0f); results.put(current.getId(), current); for (int i = 0; i < 6; i++) { Tuple<NetworkNode, Integer> neighbor = getNextNeighborAt(node, i, 0, destinations); if (neighbor == null) { continue; } current.weightedNeighbors[i] = new Tuple<WeightedNetworkNode, Integer>(createWeightedNode(neighbor.getKey(), results, destinations), neighbor.getVal()); } return current; }
Example #10
Source File: BlockTFBattery.java From TofuCraftReload with MIT License | 6 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { ItemStack stack = playerIn.getHeldItem(hand); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityTofuBattery) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(ItemHandlerHelper.copyStackWithSize(stack, 1)); if (handler != null) { FluidUtil.interactWithFluidHandler(playerIn, hand, tileentity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)); return true; } else { playerIn.openGui(TofuMain.instance, TofuGuiHandler.ID_BATTERY_GUI, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } } return true; }
Example #11
Source File: GTTileMagicEnergyAbsorber.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
private void checkForEndPortal() { if (world.getTotalWorldTime() % 100 == 0) { this.isAbovePortal = world.getBlockState(this.pos.offset(EnumFacing.DOWN)).getBlock() == Blocks.END_PORTAL; this.updateGui(); if (this.portalMode && this.isAbovePortal) { if (world.rand.nextInt(512) == 0 && GTUtility.tryResetStrongholdPortal(world, pos)) { this.isAbovePortal = false; this.updateGui(); return; } if (GTConfig.general.oneMagicAbsorberPerEndPortal && GTUtility.tryExplodeOtherAbsorbers(this.world, this.pos)) { // TODO something here } } } }
Example #12
Source File: TidalGeneratorTileEntity.java From EmergingTechnology with MIT License | 5 votes |
@Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityEnergy.ENERGY) return CapabilityEnergy.ENERGY.cast(this.generatorEnergyHandler); if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) return CapabilityAnimation.ANIMATION_CAPABILITY.cast(getAnimator()); return super.getCapability(capability, facing); }
Example #13
Source File: RenderEventHandler.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void renderPortalPanelText(World world, BlockPos pos, BlockEnderUtilities block, EntityPlayer player, float partialTicks) { IBlockState state = world.getBlockState(pos); TileEntityPortalPanel te = BlockEnderUtilitiesTileEntity.getTileEntitySafely(world, pos, TileEntityPortalPanel.class); if (te != null) { EnumFacing facing = state.getValue(block.propFacing); Integer elementId = block.getPointedElementId(world, pos, facing, player); String name; if (elementId != null && elementId >= 0 && elementId <= 7) { name = te.getTargetDisplayName(elementId); } else { name = te.getPanelDisplayName(); } if (StringUtils.isBlank(name) == false && name.length() > 0) { this.renderPortalPanelText(name, player, pos, facing, partialTicks); } } }
Example #14
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 #15
Source File: FluidHandlerEnderBucket.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this); } return null; }
Example #16
Source File: FluidPipeNet.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void destroyNetwork(boolean isLeaking, boolean isBurning) { World world = worldData.getWorld(); ((WorldFluidPipeNet) (Object) worldData).removePipeNet(this); for (BlockPos nodePos : getAllNodes().keySet()) { TileEntity tileEntity = world.getTileEntity(nodePos); if (tileEntity instanceof TileEntityFluidPipe) { if (isBurning) { world.setBlockState(nodePos, Blocks.FIRE.getDefaultState()); } else { world.setBlockToAir(nodePos); } } else if (GTValues.isModLoaded(GTValues.MODID_FMP)) { removeMultipartPipePartFromTile(tileEntity); } Random random = world.rand; if (isBurning) { TileEntityFluidPipe.spawnParticles(world, nodePos, EnumFacing.UP, EnumParticleTypes.FLAME, 3 + random.nextInt(2), random); if (random.nextInt(4) == 0) { TileEntityFluidPipe.setNeighboursToFire(world, nodePos); } } if (isLeaking) { if (world.rand.nextInt(isBurning ? 3 : 7) == 0) { world.createExplosion(null, nodePos.getX() + 0.5, nodePos.getY() + 0.5, nodePos.getZ() + 0.5, 1.0f + world.rand.nextFloat(), false); } } } }
Example #17
Source File: TileEntityInserter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setFacing(EnumFacing facing) { this.facingOpposite = facing.getOpposite(); super.setFacing(facing); this.syncSideConfigs(); }
Example #18
Source File: BlockPeripheral.java From AgriCraft with MIT License | 5 votes |
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } if (!world.isRemote) { player.openGui(AgriCraft.instance, GuiHandler.PERIPHERAL_GUI_ID, world, pos.getX(), pos.getY(), pos.getZ()); } return true; }
Example #19
Source File: RenderBlockCustomWood.java From AgriCraft with MIT License | 5 votes |
@Override public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, B block, EnumFacing side) { if (state instanceof IExtendedBlockState) { // Get the custom Wood Type. final CustomWoodType type = CustomWoodTypeRegistry.getFromState(state).orElse(CustomWoodTypeRegistry.DEFAULT); // Render the block with the given wood type. this.renderWorldBlockWoodStatic(tessellator, (IExtendedBlockState) state, block, side, type.getIcon()); } }
Example #20
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public boolean useHoeToPlant(ItemStack toolStack, EntityPlayer player, EnumHand hand, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (UtilItemModular.useEnderCharge(toolStack, ENDER_CHARGE_COST, true) == false) { return false; } IItemHandler inv = this.getLinkedInventoryWithChecks(toolStack, player); if (inv != null) { for (int slot = 0; slot < inv.getSlots(); slot++) { if (this.plantItemFromInventorySlot(world, player, hand, inv, slot, pos, side, hitX, hitY, hitZ)) { // Use Ender Charge if planting from a remote inventory if (DropsMode.fromStack(toolStack) == DropsMode.REMOTE) { UtilItemModular.useEnderCharge(toolStack, ENDER_CHARGE_COST, false); } Effects.addItemTeleportEffects(world, pos); return true; } } } return false; }
Example #21
Source File: BlockMinecoprocessor.java From Minecoprocessors with GNU General Public License v3.0 | 5 votes |
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState state = getDefaultState() .withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(ACTIVE, Boolean.valueOf((meta & 8) > 0)) .withProperty(OVERCLOCKED, Boolean.valueOf((meta & 4) > 0)); return state; }
Example #22
Source File: BlockEngineeringTable.java From Cyberware with MIT License | 5 votes |
public BlockEngineeringTable() { super(Material.IRON); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HALF, EnumEngineeringHalf.LOWER)); setHardness(5.0F); setResistance(10.0F); setSoundType(SoundType.METAL); String name = "engineeringTable"; this.setRegistryName(name); GameRegistry.register(this); ib = new ItemEngineeringTable(this); ib.setRegistryName(name); GameRegistry.register(ib); this.setUnlocalizedName(Cyberware.MODID + "." + name); ib.setUnlocalizedName(Cyberware.MODID + "." + name); ib.setCreativeTab(Cyberware.creativeTab); GameRegistry.registerTileEntity(TileEntityEngineeringTable.class, Cyberware.MODID + ":" + name); GameRegistry.registerTileEntity(TileEntityEngineeringDummy.class, Cyberware.MODID + ":" + name + "Dummy"); CyberwareContent.items.add(ib); }
Example #23
Source File: BlockMethods.java From pycode-minecraft with MIT License | 5 votes |
public void cube(PyObject[] args, String[] kws) { if (this.world == null || this.world.isRemote) return; ArgParser r = new ArgParser("line", s("pos", "width", "depth", "height", "blockname"), PyRegistry.BLOCK_VARIATIONS); r.parse(args, kws); MyBlockPos mpos = (MyBlockPos)r.get("pos").__tojava__(MyBlockPos.class); ShapeGen.cube(r, this.world, mpos.blockPos, EnumFacing.NORTH); }
Example #24
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 #25
Source File: BatteryTileEntity.java From EmergingTechnology with MIT License | 5 votes |
@Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityEnergy.ENERGY) { if (facing == getFacing()) { return CapabilityEnergy.ENERGY.cast(this.consumerStorageHandler); } else { return CapabilityEnergy.ENERGY.cast(this.generatorStorageHandler); } } return super.getCapability(capability, facing); }
Example #26
Source File: BlockWorldState.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public IBlockState getOffsetState(EnumFacing face) { if (pos instanceof MutableBlockPos) { ((MutableBlockPos) pos).move(face); IBlockState blockState = world.getBlockState(pos); ((MutableBlockPos) pos).move(face.getOpposite()); return blockState; } return world.getBlockState(this.pos.offset(face)); }
Example #27
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean canClickOnAdjacentBlockToPlaceSingleSlabAt(BlockPos targetBlockPos, IBlockState targetState, EnumFacing side, World worldClient) { BlockPos posSide = targetBlockPos.offset(side); IBlockState stateSide = worldClient.getBlockState(posSide); return PlacementUtils.isReplaceable(worldClient, posSide, false) == false && (side.getAxis() != EnumFacing.Axis.Y || clientBlockIsSameMaterialSingleSlab(targetState, stateSide) == false || stateSide.getValue(BlockSlab.HALF) != targetState.getValue(BlockSlab.HALF)); }
Example #28
Source File: DijkstraRouter.java From Logistics-Pipes-2 with MIT License | 5 votes |
private void pushToRouteUntillParent(NetworkNode current, ArrayDeque<Tuple<UUID, EnumFacing>> route) throws InterruptedException { NetworkNode parent = current.parent.getKey(); EnumFacing direction = current.parent.getVal(); int parentDirection = direction.getOpposite().getIndex(); NetworkNode help = current; while(help.getId() != parent.getId()) { help = help.getNeighborAt(parentDirection); route.push(new Tuple<UUID, EnumFacing>(help.getId(), direction)); //help.getMember().spawnParticle(1.0f, 0.549f, 0.0f); Thread.sleep(120); } }
Example #29
Source File: ItemLocationBound.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public void setTarget(ItemStack stack, EntityPlayer player, boolean storeRotation) { BlockPos pos = player.getPosition(); double hitX = player.posX - pos.getX(); double hitY = player.posY - pos.getY(); double hitZ = player.posZ - pos.getZ(); //System.out.printf("x: %d y: %d z: %d hit: %.3f %.3f %.3f\n", x, y, z, hitX, hitY, hitZ); boolean adjustPosHit = stack.getItem() == EnderUtilitiesItems.LINK_CRYSTAL && ((ItemLinkCrystal) stack.getItem()).getModuleTier(stack) == ItemLinkCrystal.TYPE_LOCATION; this.setTarget(stack, player, pos, EnumFacing.UP, hitX, hitY, hitZ, adjustPosHit, storeRotation); }
Example #30
Source File: WindTileEntity.java From EmergingTechnology with MIT License | 5 votes |
@Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityEnergy.ENERGY) return true; if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) return true; return super.hasCapability(capability, facing); }