Java Code Examples for net.minecraft.util.EnumFacing

The following examples show how to use net.minecraft.util.EnumFacing. These examples are extracted from open source projects.
Example 1
Project: Signals   File: WorldGeneratorSignals.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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
Project: OpenModsLib   File: EvalModelTest.java    License: MIT License 6 votes vote down vote up
@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
Project: TofuCraftReload   File: StructureTofuVillagePieces.java    License: MIT License 6 votes vote down vote up
@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
Project: EmergingTechnology   File: HarvesterTileEntity.java    License: MIT License 6 votes vote down vote up
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
Project: CommunityMod   File: BlockPackager.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
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
Project: OpenModsLib   File: BlockManipulator.java    License: MIT License 6 votes vote down vote up
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
Project: AdvancedRocketry   File: BlockTorchUnlit.java    License: MIT License 6 votes vote down vote up
@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
Project: GregTech   File: InvPipeRenderer.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@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
Project: Logistics-Pipes-2   File: NetworkSimplifier.java    License: MIT License 6 votes vote down vote up
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
Project: TofuCraftReload   File: BlockTFBattery.java    License: MIT License 6 votes vote down vote up
@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
Project: GT-Classic   File: GTTileMagicEnergyAbsorber.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
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
Project: EmergingTechnology   File: TidalGeneratorTileEntity.java    License: MIT License 5 votes vote down vote up
@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
Project: enderutilities   File: RenderEventHandler.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: TofuCraftReload   File: BlockAdvancedAggregator.java    License: MIT License 5 votes vote down vote up
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
Project: enderutilities   File: FluidHandlerEnderBucket.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@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
Project: GregTech   File: FluidPipeNet.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: enderutilities   File: TileEntityInserter.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setFacing(EnumFacing facing)
{
    this.facingOpposite = facing.getOpposite();

    super.setFacing(facing);

    this.syncSideConfigs();
}
 
Example 18
Project: AgriCraft   File: BlockPeripheral.java    License: MIT License 5 votes vote down vote up
@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
Project: AgriCraft   File: RenderBlockCustomWood.java    License: MIT License 5 votes vote down vote up
@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
Project: enderutilities   File: ItemEnderTool.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: Minecoprocessors   File: BlockMinecoprocessor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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
Project: Cyberware   File: BlockEngineeringTable.java    License: MIT License 5 votes vote down vote up
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
Project: pycode-minecraft   File: BlockMethods.java    License: MIT License 5 votes vote down vote up
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
Project: WearableBackpacks   File: BlockBackpack.java    License: MIT License 5 votes vote down vote up
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
Project: EmergingTechnology   File: BatteryTileEntity.java    License: MIT License 5 votes vote down vote up
@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
Project: GregTech   File: BlockWorldState.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: litematica   File: EasyPlaceUtils.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: Logistics-Pipes-2   File: DijkstraRouter.java    License: MIT License 5 votes vote down vote up
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
Project: enderutilities   File: ItemLocationBound.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
Project: EmergingTechnology   File: WindTileEntity.java    License: MIT License 5 votes vote down vote up
@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);
}
 
Example 31
Project: TofuCraftReload   File: StructureTofuMineshaftPieces.java    License: MIT License 5 votes vote down vote up
public static StructureBoundingBox findCrossing(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing) {
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);

    if (rand.nextInt(4) == 0) {
        structureboundingbox.maxY += 4;
    }

    switch (facing) {
        case NORTH:
        default:
            structureboundingbox.minX = x - 1;
            structureboundingbox.maxX = x + 3;
            structureboundingbox.minZ = z - 4;
            break;
        case SOUTH:
            structureboundingbox.minX = x - 1;
            structureboundingbox.maxX = x + 3;
            structureboundingbox.maxZ = z + 3 + 1;
            break;
        case WEST:
            structureboundingbox.minX = x - 4;
            structureboundingbox.minZ = z - 1;
            structureboundingbox.maxZ = z + 3;
            break;
        case EAST:
            structureboundingbox.maxX = x + 3 + 1;
            structureboundingbox.minZ = z - 1;
            structureboundingbox.maxZ = z + 3;
    }

    return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
}
 
Example 32
Project: enderutilities   File: ItemBuildersWand.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void moveEndPosition(ItemStack stack, EntityPlayer player, boolean reverse)
{
    EnumFacing direction = EntityUtils.getClosestLookingDirection(player);
    Mode mode = Mode.getMode(stack);
    BlockPosEU posStart = mode == Mode.CUBE || mode == Mode.WALLS ?
            this.getPosition(stack, mode, POS_START) : this.getPerTemplateAreaCorner(stack, mode, POS_START);
    BlockPosEU posEnd = this.getPosition(stack, mode, POS_END);

    if (posEnd == null)
    {
        posEnd = posStart;
    }

    if (posStart != null && posEnd != null)
    {
        int v = reverse ? 1 : -1;
        posEnd = posEnd.add(direction.getXOffset() * v, direction.getYOffset() * v, direction.getZOffset() * v);

        if (mode == Mode.WALLS || mode == Mode.CUBE)
        {
            this.setPosition(posEnd, false, stack, player);
        }
        else
        {
            this.setPerTemplateAreaCorner(posEnd, mode, false, stack, player);
            this.setAreaFacing(stack, mode, PositionUtils.getFacingFromPositions(posStart, posEnd));
            this.setMirror(stack, mode, Mirror.NONE);
        }
    }
}
 
Example 33
Project: OpenModsLib   File: BlockRotationModeTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testTopEqualsUpForAllHorizontals() {
	for (EnumFacing facing : EnumFacing.HORIZONTALS) {
		final Orientation orientation = mode.getOrientationFacing(facing);
		Assert.assertNotNull(facing.toString(), orientation);
		Assert.assertEquals(facing.toString(), EnumFacing.UP, mode.getTop(orientation));
	}
}
 
Example 34
Project: customstuff4   File: TileEntityModuleInventory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
{
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY &&
        (facing == null || ArrayUtils.contains(supplier.sides, facing)))
    {
        return (T) invHandler;
    }

    return null;
}
 
Example 35
Project: GregTech   File: LargeTurbineRenderer.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderSided(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, EnumFacing side, boolean hasBase, boolean hasRotor, boolean isActive, int rotorRGB) {
    Matrix4 cornerOffset = null;
    switch (side.getAxis()) {
        case X:
            cornerOffset = translation.copy().translate(0.01 * side.getFrontOffsetX(), -1.0, -1.0);
            cornerOffset.scale(1.0, 3.0, 3.0);
            break;
        case Z:
            cornerOffset = translation.copy().translate(-1.0, -1.0, 0.01 * side.getFrontOffsetZ());
            cornerOffset.scale(3.0, 3.0, 1.0);
            break;
        case Y:
            cornerOffset = translation.copy().translate(-1.0, 0.01 * side.getFrontOffsetY(), -1.0);
            cornerOffset.scale(3.0, 1.0, 3.0);
            break;
    }
    if (hasBase) {
        Textures.renderFace(renderState, cornerOffset, pipeline, side, Cuboid6.full, baseRingSprite);
        renderState.brightness = 0xF000F0;
        renderState.colour = 0xFFFFFFFF;
        Textures.renderFace(renderState, cornerOffset, new IVertexOperation[0], side, Cuboid6.full, baseBackgroundSprite);
    }
    if (hasRotor) {
        TextureAtlasSprite sprite = isActive ? activeBladeSprite : idleBladeSprite;
        IVertexOperation[] color = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(rotorRGB)));
        Textures.renderFace(renderState, cornerOffset, color, side, Cuboid6.full, sprite);
    }
}
 
Example 36
Project: Sakura_mod   File: BlockTaiko.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if(RecipesUtil.containsMatch(false, OreDictionary.getOres("stickWood"), playerIn.getHeldItem(hand))){
		worldIn.playSound(playerIn, pos, CommonProxy.TAIKO, SoundCategory.BLOCKS, 1.2F, 1.2F);
		playerIn.swingArm(hand);
		}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example 37
Project: GregTech   File: FacadeBlockAccess.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public FacadeBlockAccess(IBlockAccess world, BlockPos pos, EnumFacing side, IBlockState state) {

        this.world = world;
        this.pos = pos;
        this.side = side;
        this.state = state;
    }
 
Example 38
Project: GT-Classic   File: GTModelMortar.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
protected BlockPartFace createWallFaceNS(EnumFacing side) {
	if (side == EnumFacing.UP || side == EnumFacing.DOWN) {
		return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 12.0F,
				2.0F }, 0));
	}
	if (side == EnumFacing.NORTH || side == EnumFacing.SOUTH) {
		return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 10.0F,
				5.0F }, 0));
	}
	return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 2.0F, 5.0F }, 0));
}
 
Example 39
Project: EmergingTechnology   File: ScaffolderTileEntity.java    License: MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example 40
Project: Production-Line   File: BlockFluidKineticGenerator.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        player.openGui(ProductionLine.getInstance(), GuiHandler.EnumGui.FluidKineticGenerator.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
    }
    return true;
}