Skip to content

Commit

Permalink
Ported portal rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
maximumpower55 committed Oct 4, 2023
1 parent 71c4e6d commit 3b55261
Show file tree
Hide file tree
Showing 29 changed files with 467 additions and 488 deletions.
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

0 comments on commit 3b55261

Please sign in to comment.