Search in sources :

Example 31 with Direction

use of net.minecraft.util.Direction in project AgriCraft by AgriCraft.

the class BotanyPotsPlantRenderer method fetchQuads.

protected List<BakedQuad> fetchQuads(IAgriWeed weed, IAgriGrowthStage stage, Direction... sides) {
    List<BakedQuad> quads = Lists.newArrayList();
    for (Direction dir : sides) {
        quads.addAll(AgriPlantModelBridge.getOrBakeQuads(weed, stage, dir));
    }
    quads.addAll(AgriPlantModelBridge.getOrBakeQuads(weed, stage, null));
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.model.BakedQuad) Direction(net.minecraft.util.Direction)

Example 32 with Direction

use of net.minecraft.util.Direction in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzerSeedRenderer method renderGenome.

protected void renderGenome(TileEntitySeedAnalyzer tile, float partialTick, MatrixStack transforms, IRenderTypeBuffer buffer) {
    // fetch genes
    List<IAgriGenePair<?>> genes = tile.getGenesToRender();
    if (genes == null) {
        // should never be possible
        return;
    }
    // push a new matrix to the stack
    transforms.push();
    // fetch helpers
    SeedAnalyzerViewPointHandler viewHandler = SeedAnalyzerViewPointHandler.getInstance();
    AgriGenomeRenderer renderer = AgriGenomeRenderer.getInstance();
    // fetch scroll position
    int index = viewHandler.getScrollIndex();
    float partial = viewHandler.getPartialScrollProgress(partialTick);
    // fetch orientation
    BlockState state = tile.getBlockState();
    Direction dir = BlockSeedAnalyzer.ORIENTATION.fetch(state);
    // helix dimensions
    float h = Constants.HALF;
    float r = h / 10;
    // transform to the desired position
    float dx = Constants.HALF + Constants.UNIT * dir.getXOffset();
    float dy = 5 * Constants.UNIT;
    float dz = Constants.HALF + Constants.UNIT * dir.getZOffset();
    transforms.translate(dx, dy, dz);
    transforms.rotate(new Quaternion(Vector3f.YP, tile.getHorizontalAngle(), true));
    // render the helix
    renderer.renderDoubleHelix(genes, transforms, buffer, index, partial, r, h, 1.0F, false);
    // render the text
    if (index >= 0 && index < genes.size()) {
        transforms.push();
        transforms.translate(0, 0, -3 * Constants.UNIT);
        transforms.rotate(TEXT_ROTATION);
        float scale = 2.0F / Math.max(this.getScaledWindowWidth(), this.getScaledWindowHeight());
        transforms.scale(scale, scale, 1);
        renderer.renderTextOverlay(transforms, genes.get(index));
        transforms.pop();
    }
    // pop the matrix off the stack
    transforms.pop();
}
Also used : IAgriGenePair(com.infinityraider.agricraft.api.v1.genetics.IAgriGenePair) BlockState(net.minecraft.block.BlockState) Quaternion(net.minecraft.util.math.vector.Quaternion) SeedAnalyzerViewPointHandler(com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler) Direction(net.minecraft.util.Direction) AgriGenomeRenderer(com.infinityraider.agricraft.render.plant.AgriGenomeRenderer)

Example 33 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class BlockGateBase method getStateForPlacement.

@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
    FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos());
    Direction face = context.getClickedFace();
    return this.defaultBlockState().setValue(ROTATION, context.getHorizontalDirection().getOpposite().get2DDataValue()).setValue(FACING, face).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER);
}
Also used : Direction(net.minecraft.util.Direction) FluidState(net.minecraft.fluid.FluidState) Nullable(javax.annotation.Nullable)

Example 34 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class RenderEngine method render.

@Override
public void render(TileEngine engine, float f, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int i, int i1) {
    World world = engine.getLevel();
    BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
    BlockPos pos = engine.getBlockPos();
    BlockState state = BPBlocks.engine.defaultBlockState().setValue(BlockEngine.FACING, engine.getOrientation());
    Direction facing = engine.getOrientation();
    matrixStack.pushPose();
    float rotationX = 90.0F;
    float rotation = 0.0F;
    if (facing == Direction.NORTH) {
        matrixStack.translate(0, 1, 0);
        rotation = 0F;
    } else if (facing == Direction.SOUTH) {
        matrixStack.translate(1, 1, 1);
        rotation = 180F;
    } else if (facing == Direction.EAST) {
        matrixStack.translate(1, 1, 0);
        rotation = 90F;
    } else if (facing == Direction.WEST) {
        matrixStack.translate(0, 1, 1);
        rotation = -90F;
    } else if (facing == Direction.UP) {
        matrixStack.translate(0, 1, 1);
        rotationX = 180F;
    } else if (facing == Direction.DOWN) {
        rotationX = 0F;
    }
    matrixStack.mulPose(Vector3f.XP.rotationDegrees(rotationX));
    matrixStack.mulPose(Vector3f.ZP.rotationDegrees(rotation));
    matrixStack.pushPose();
    float f2 = 0;
    if (engine.isActive) {
        f += engine.pumpTick;
        if (engine.pumpSpeed > 0) {
            f /= engine.pumpSpeed;
        }
        f2 = ((float) (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)) / 4);
    }
    matrixStack.translate(0, f2, 0);
    IBakedModel glider = dispatcher.getBlockModel(state.setValue(BlockEngine.GLIDER, true));
    // Render the glider
    IVertexBuilder builder = iRenderTypeBuffer.getBuffer(RenderType.cutout());
    dispatcher.getModelRenderer().renderModel(world, glider, state.setValue(BlockEngine.GLIDER, true), pos, matrixStack, builder, false, new Random(), 0, 0, EmptyModelData.INSTANCE);
    matrixStack.popPose();
    matrixStack.pushPose();
    matrixStack.translate(0.5, 0, 0.5);
    long angle = engine.isActive ? (System.currentTimeMillis() / 10) % 360 : 0;
    matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
    matrixStack.translate(-0.5, 0, -0.5);
    IBakedModel gear = dispatcher.getBlockModel(state.setValue(BlockEngine.GEAR, true));
    // Render the rotating cog
    dispatcher.getModelRenderer().renderModel(world, gear, state.setValue(BlockEngine.GEAR, true), pos, matrixStack, iRenderTypeBuffer.getBuffer(RenderType.cutout()), false, new Random(), 0, 0, EmptyModelData.INSTANCE);
    matrixStack.popPose();
    matrixStack.popPose();
}
Also used : BlockState(net.minecraft.block.BlockState) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) World(net.minecraft.world.World) Direction(net.minecraft.util.Direction) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 35 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class TileMachineBase method ejectItems.

private void ejectItems() {
    for (Iterator<TubeStack> iterator = internalItemStackBuffer.iterator(); iterator.hasNext(); ) {
        TubeStack tubeStack = iterator.next();
        if (IOHelper.canInterfaceWith(getTileCache(getOutputDirection()), getFacingDirection())) {
            ItemStack returnedStack = IOHelper.insert(getTileCache(getOutputDirection()), tubeStack.stack, getFacingDirection(), tubeStack.color, false);
            if (returnedStack.isEmpty()) {
                iterator.remove();
                setChanged();
                if (!ejectionScheduled)
                    break;
            } else if (returnedStack.getCount() != tubeStack.stack.getCount()) {
                setChanged();
                if (!ejectionScheduled)
                    break;
            } else {
                break;
            }
        } else if (spawnItemsInWorld) {
            Direction direction = getFacingDirection().getOpposite();
            Block block = level.getBlockState(worldPosition.relative(direction)).getBlock();
            if (!level.getBlockState(worldPosition.relative(direction)).canOcclude() || block instanceof IFluidBlock) {
                ejectItemInWorld(tubeStack.stack, direction);
                iterator.remove();
                setChanged();
            } else {
                break;
            }
        }
    }
}
Also used : TubeStack(com.bluepowermod.container.stack.TubeStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.Direction)

Aggregations

Direction (net.minecraft.util.Direction)50 BlockState (net.minecraft.block.BlockState)18 TileEntity (net.minecraft.tileentity.TileEntity)17 BlockPos (net.minecraft.util.math.BlockPos)15 ItemStack (net.minecraft.item.ItemStack)12 Block (net.minecraft.block.Block)10 Nonnull (javax.annotation.Nonnull)8 Nullable (javax.annotation.Nullable)8 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 IPowerBase (com.bluepowermod.api.power.IPowerBase)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 World (net.minecraft.world.World)5 Capability (net.minecraftforge.common.capabilities.Capability)5 BlutricityStorage (com.bluepowermod.api.power.BlutricityStorage)4 CapabilityBlutricity (com.bluepowermod.api.power.CapabilityBlutricity)4 EnergyHelper (com.bluepowermod.helper.EnergyHelper)4 BPTileEntityType (com.bluepowermod.tile.BPTileEntityType)4 TileMachineBase (com.bluepowermod.tile.TileMachineBase)4 INBT (net.minecraft.nbt.INBT)4 LazyOptional (net.minecraftforge.common.util.LazyOptional)4