Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate portal rendering over #123

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fusionflux.portalcubed;

import com.fusionflux.portalcubed.client.render.portal.PortalRenderers;
import eu.midnightdust.lib.config.MidnightConfig;

@SuppressWarnings("CanBeFinal")
Expand All @@ -16,7 +15,7 @@ public class PortalCubedConfig extends MidnightConfig {
@Entry @Client public static boolean portalHudMode = false;
@Entry(min = 0, max = 100, isSlider = true) @Client public static int gelOverlayOpacity = 100;
@Entry @Client public static boolean staticPortalItemDrops = true;
@Entry @Client public static PortalRenderers renderer = PortalRenderers.DISABLED;
@Entry(min = 0, max = 4, isSlider = true) @Client public static int portalRenderingLayers = 1;
@Entry @Client public static boolean crossPortalEntityRendering = true;
@Entry(min = 0, max = 1000, isSlider = true) @Client public static int portalSmoothTime = 250;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import com.fusionflux.portalcubed.client.render.entity.animatedtextures.AnimatedEntityTextures;
import com.fusionflux.portalcubed.client.render.entity.model.*;
import com.fusionflux.portalcubed.client.render.portal.PortalRenderPhase;
import com.fusionflux.portalcubed.client.render.portal.PortalRendererImpl;
import com.fusionflux.portalcubed.client.render.portal.PortalRenderers;
import com.fusionflux.portalcubed.client.render.portal.PortalRendering;
import com.fusionflux.portalcubed.entity.Portal;
import com.fusionflux.portalcubed.entity.PortalCubedEntities;
import com.fusionflux.portalcubed.fluids.PortalCubedFluids;
Expand Down Expand Up @@ -75,7 +74,6 @@
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang3.mutable.MutableDouble;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
Expand Down Expand Up @@ -136,9 +134,6 @@ public class PortalCubedClient implements ClientModInitializer {
public static int gelOverlayTimer = -1;
public static ResourceLocation gelOverlayTexture = TextureManager.INTENTIONAL_MISSING_TEXTURE;

private static PortalRendererImpl renderer;
private static PortalRenderers rendererType;

public static IPQuaternion cameraInterpStart;
public static long cameraInterpStartTime;

Expand Down Expand Up @@ -320,6 +315,7 @@ Items.LIGHT, new ResourceLocation("level")
RenderSystem.depthFunc(GL11.GL_LEQUAL);
RenderSystem.enableCull();
});
PortalRendering.init();

PortalBlocksLoader.initClient();

Expand Down Expand Up @@ -804,15 +800,6 @@ public static int globalAdvancementsSize() {
return GLOBAL_ADVANCEMENTS.size();
}

@NotNull
public static PortalRendererImpl getRenderer() {
if (rendererType != PortalCubedConfig.renderer) {
rendererType = PortalCubedConfig.renderer;
renderer = rendererType.creator.get();
}
return renderer;
}

public static Optional<IPQuaternion> interpCamera() {
final long time = System.currentTimeMillis();
final long endTime = PortalCubedClient.cameraInterpStartTime + PortalCubedConfig.portalSmoothTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fusionflux.portalcubed.client.PortalCubedClient;
import com.fusionflux.portalcubed.client.render.entity.model.PortalModel;
import com.fusionflux.portalcubed.client.render.portal.PortalRenderPhase;
import com.fusionflux.portalcubed.client.render.portal.PortalRendererImpl;
import com.fusionflux.portalcubed.entity.Portal;
import com.fusionflux.portalcubed.util.GeneralUtil;
import com.mojang.blaze3d.vertex.PoseStack;
Expand Down Expand Up @@ -69,7 +68,7 @@ public void render(@NotNull Portal entity, float yaw, float tickDelta, @NotNull
matrices.scale(progress, progress, progress);
}

renderPortal(matrices, vertexConsumers, entity, light, r, g, b, tickDelta);
model.renderToBuffer(matrices, vertexConsumers.getBuffer(RenderType.entityTranslucentEmissive(getTextureLocation(entity))), light, OverlayTexture.NO_OVERLAY, r, g, b, 1F);

matrices.popPose();

Expand Down Expand Up @@ -101,27 +100,6 @@ public void render(@NotNull Portal entity, float yaw, float tickDelta, @NotNull
}
}

public void renderPortal(
PoseStack poseStack,
MultiBufferSource vertexConsumers,
Portal entity,
int light,
int r,
int g,
int b,
float tickDelta
) {
final PortalRendererImpl renderer = PortalCubedClient.getRenderer();
final boolean renderContents = renderPhase == renderer.targetPhase() && renderer.enabled(entity);
if (renderContents) {
renderer.preRender(entity, tickDelta, poseStack, vertexConsumers);
}
model.renderToBuffer(poseStack, vertexConsumers.getBuffer(RenderType.entityTranslucentEmissive(getTextureLocation(entity))), light, OverlayTexture.NO_OVERLAY, r, g, b, 1F);
if (renderContents) {
renderer.postRender(entity, tickDelta, poseStack, vertexConsumers);
}
}

private void renderOtherEntities(Portal entity, PoseStack poseStack, float tickDelta, MultiBufferSource buffer, int packedLight) {
if (renderPhase != PortalRenderPhase.ENTITY || !entity.getActive()) return;
final UUID otherUuid = entity.getLinkedPortalUUID().orElse(null);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.fusionflux.portalcubed.client.render.portal;

public enum PortalRenderPhase {
ENTITY, TRACER, FINAL
ENTITY, TRACER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.fusionflux.portalcubed.client.render.portal;

import com.mojang.blaze3d.pipeline.TextureTarget;

import net.minecraft.client.Minecraft;

/**
* Stencil code is in {@link com.fusionflux.portalcubed.mixin.client.RenderTargetMixin}
*/
public final class PortalRenderTarget extends TextureTarget {
PortalRenderTarget(int width, int height) {
super(width, height, true, Minecraft.ON_OSX);
}
}

This file was deleted.

Loading
Loading