use of net.minecraft.item.CompassItem in project Structurize by ldtteam.
the class BlueprintRenderer method draw.
/**
* Draws structure into world.
*/
public void draw(final BlockPos pos, final MatrixStack matrixStack, final float partialTicks) {
Minecraft.getInstance().getProfiler().push("struct_render_init");
if (Settings.instance.shouldRefresh()) {
init();
}
Minecraft.getInstance().getProfiler().popPush("struct_render_blocks");
final Minecraft mc = Minecraft.getInstance();
final Vector3d viewPosition = mc.gameRenderer.getMainCamera().getPosition();
final BlockPos primaryBlockOffset = blockAccess.getBlueprint().getPrimaryBlockOffset();
final int x = pos.getX() - primaryBlockOffset.getX();
final int y = pos.getY() - primaryBlockOffset.getY();
final int z = pos.getZ() - primaryBlockOffset.getZ();
// missing clipping helper? frustum?
// missing chunk system and render distance!
matrixStack.pushPose();
matrixStack.translate(x - viewPosition.x(), y - viewPosition.y(), z - viewPosition.z());
final Matrix4f rawPosMatrix = matrixStack.last().pose();
// Render blocks
Minecraft.getInstance().getProfiler().popPush("struct_render_blocks_finish");
renderBlockLayer(RenderType.solid(), rawPosMatrix);
// FORGE: fix flickering leaves when mods mess up the blurMipmap settings
mc.getModelManager().getAtlas(AtlasTexture.LOCATION_BLOCKS).setBlurMipmap(false, mc.options.mipmapLevels > 0);
renderBlockLayer(RenderType.cutoutMipped(), rawPosMatrix);
mc.getModelManager().getAtlas(AtlasTexture.LOCATION_BLOCKS).restoreLastBlurMipmap();
renderBlockLayer(RenderType.cutout(), rawPosMatrix);
OptifineCompat.getInstance().endTerrainBeginEntities();
Minecraft.getInstance().getProfiler().popPush("struct_render_entities");
final IRenderTypeBuffer.Impl renderBufferSource = ClientEventSubscriber.renderBuffers.bufferSource();
// Entities
// if clipping etc., see WorldRenderer for what's missing
entities.forEach(entity -> {
if (entity instanceof ItemFrameEntity && ((ItemFrameEntity) entity).getItem().getItem() instanceof CompassItem) {
final ItemFrameEntity copy = EntityType.ITEM_FRAME.create(blockAccess);
copy.restoreFrom(entity);
copy.setItem(ItemStack.EMPTY);
entity = copy;
}
OptifineCompat.getInstance().preRenderEntity(entity);
Minecraft.getInstance().getEntityRenderDispatcher().render(entity, entity.getX(), entity.getY(), entity.getZ(), MathHelper.lerp(partialTicks, entity.yRotO, entity.yRot), 0, matrixStack, renderBufferSource, 200);
});
Minecraft.getInstance().getProfiler().popPush("struct_render_entities_finish");
renderBufferSource.endBatch(RenderType.entitySolid(AtlasTexture.LOCATION_BLOCKS));
renderBufferSource.endBatch(RenderType.entityCutout(AtlasTexture.LOCATION_BLOCKS));
renderBufferSource.endBatch(RenderType.entityCutoutNoCull(AtlasTexture.LOCATION_BLOCKS));
renderBufferSource.endBatch(RenderType.entitySmoothCutout(AtlasTexture.LOCATION_BLOCKS));
OptifineCompat.getInstance().endEntitiesBeginBlockEntities();
// Block entities
Minecraft.getInstance().getProfiler().popPush("struct_render_blockentities");
final ActiveRenderInfo oldActiveRenderInfo = TileEntityRendererDispatcher.instance.camera;
final World oldWorld = TileEntityRendererDispatcher.instance.level;
TileEntityRendererDispatcher.instance.camera = new ActiveRenderInfo();
TileEntityRendererDispatcher.instance.camera.setPosition(viewPosition.subtract(x, y, z));
TileEntityRendererDispatcher.instance.level = blockAccess;
tileEntities.forEach(tileEntity -> {
final BlockPos tePos = tileEntity.getBlockPos();
matrixStack.pushPose();
matrixStack.translate(tePos.getX(), tePos.getY(), tePos.getZ());
OptifineCompat.getInstance().preRenderBlockEntity(tileEntity);
TileEntityRendererDispatcher.instance.render(tileEntity, partialTicks, matrixStack, renderBufferSource);
matrixStack.popPose();
});
TileEntityRendererDispatcher.instance.camera = oldActiveRenderInfo;
TileEntityRendererDispatcher.instance.level = oldWorld;
Minecraft.getInstance().getProfiler().popPush("struct_render_blockentities_finish");
renderBufferSource.endBatch(RenderType.solid());
renderBufferSource.endBatch(Atlases.solidBlockSheet());
renderBufferSource.endBatch(Atlases.cutoutBlockSheet());
renderBufferSource.endBatch(Atlases.bedSheet());
renderBufferSource.endBatch(Atlases.shulkerBoxSheet());
renderBufferSource.endBatch(Atlases.signSheet());
renderBufferSource.endBatch(Atlases.chestSheet());
if (OptifineCompat.getInstance().isOptifineEnabled()) {
renderBufferSource.endBatch(Atlases.bannerSheet());
}
// not used now
ClientEventSubscriber.renderBuffers.outlineBufferSource().endOutlineBatch();
OptifineCompat.getInstance().endBlockEntitiesBeginDebug();
renderBufferSource.endBatch(Atlases.translucentCullBlockSheet());
renderBufferSource.endBatch(Atlases.bannerSheet());
renderBufferSource.endBatch(Atlases.shieldSheet());
renderBufferSource.endBatch(RenderType.armorGlint());
renderBufferSource.endBatch(RenderType.armorEntityGlint());
renderBufferSource.endBatch(RenderType.glint());
renderBufferSource.endBatch(RenderType.glintDirect());
renderBufferSource.endBatch(RenderType.glintTranslucent());
renderBufferSource.endBatch(RenderType.entityGlint());
renderBufferSource.endBatch(RenderType.entityGlintDirect());
renderBufferSource.endBatch(RenderType.waterMask());
// not used now
ClientEventSubscriber.renderBuffers.crumblingBufferSource().endBatch();
renderBufferSource.endBatch(RenderType.lines());
renderBufferSource.endBatch();
Minecraft.getInstance().getProfiler().popPush("struct_render_blocks_finish2");
OptifineCompat.getInstance().endDebugPreWaterBeginWater();
renderBlockLayer(RenderType.translucent(), rawPosMatrix);
OptifineCompat.getInstance().endWater();
renderBlockLayer(RenderType.tripwire(), rawPosMatrix);
matrixStack.popPose();
Minecraft.getInstance().getProfiler().pop();
}
Aggregations