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;
}
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();
}
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);
}
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();
}
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;
}
}
}
}
Aggregations