类net.minecraft.util.EnumFacing源码实例Demo

下面列出了怎么用net.minecraft.util.EnumFacing的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Signals   文件: WorldGeneratorSignals.java
@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);

            }
        }
    }
}
 
源代码2 项目: OpenModsLib   文件: EvalModelTest.java
@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);
}
 
@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;
}
 
源代码4 项目: EmergingTechnology   文件: HarvesterTileEntity.java
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));
}
 
源代码5 项目: CommunityMod   文件: BlockPackager.java
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;
}
 
源代码6 项目: OpenModsLib   文件: BlockManipulator.java
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;
}
 
源代码7 项目: AdvancedRocketry   文件: BlockTorchUnlit.java
@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;
}
 
源代码8 项目: GregTech   文件: InvPipeRenderer.java
@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);
        }
    }
}
 
源代码9 项目: Logistics-Pipes-2   文件: NetworkSimplifier.java
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;
}
 
源代码10 项目: TofuCraftReload   文件: BlockTFBattery.java
@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;
}
 
源代码11 项目: GT-Classic   文件: GTTileMagicEnergyAbsorber.java
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
			}
		}
	}
}
 
@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);
}
 
源代码13 项目: enderutilities   文件: RenderEventHandler.java
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);
        }
    }
}
 
源代码14 项目: TofuCraftReload   文件: BlockAdvancedAggregator.java
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);
    }
}
 
源代码15 项目: enderutilities   文件: FluidHandlerEnderBucket.java
@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;
}
 
源代码16 项目: GregTech   文件: FluidPipeNet.java
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);
            }
        }
    }
}
 
源代码17 项目: enderutilities   文件: TileEntityInserter.java
@Override
public void setFacing(EnumFacing facing)
{
    this.facingOpposite = facing.getOpposite();

    super.setFacing(facing);

    this.syncSideConfigs();
}
 
源代码18 项目: AgriCraft   文件: BlockPeripheral.java
@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;
}
 
源代码19 项目: AgriCraft   文件: RenderBlockCustomWood.java
@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());
    }
}
 
源代码20 项目: enderutilities   文件: ItemEnderTool.java
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;
}
 
源代码21 项目: Minecoprocessors   文件: BlockMinecoprocessor.java
/**
 * 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;
}
 
源代码22 项目: Cyberware   文件: BlockEngineeringTable.java
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);
}
 
源代码23 项目: pycode-minecraft   文件: BlockMethods.java
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);
}
 
源代码24 项目: 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));
	}
}
 
源代码25 项目: EmergingTechnology   文件: BatteryTileEntity.java
@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);
}
 
源代码26 项目: GregTech   文件: BlockWorldState.java
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));
}
 
源代码27 项目: litematica   文件: EasyPlaceUtils.java
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));
}
 
源代码28 项目: Logistics-Pipes-2   文件: DijkstraRouter.java
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);
	}
}
 
源代码29 项目: enderutilities   文件: ItemLocationBound.java
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);
}
 
源代码30 项目: EmergingTechnology   文件: WindTileEntity.java
@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);
}
 
 类所在包
 同包方法