Compare commits

..
Author SHA1 Message Date
kurrycat f233ba65e3 add syncProgram call to glDrawElements + glBegin 2024-10-26 13:47:26 -07:00
kurrycat c0d636d4f7 fix entities being rendered completely black 2024-10-26 12:10:52 -07:00
RecursivePineappleandDarren Eberly bd5cd350c3 Replace BlockError mixin with event handler (#671)
* Replace BlockError mixin with event handler

Something is calling TextureMap.registerIcons before preInit() sets up
the BlockError reference. While adding a null check to the mixin would
also fix this, a mixin isn't needed here since forge exposes an event
for this purpose.

* Add client sideonly for texture stitch event

---------

Co-authored-by: Darren Eberly <[email protected]>
2024-10-22 16:33:11 -04:00
kurrycat 88936d3713 fix horizon rendering before camera transform (#669) 2024-10-21 16:31:44 -04:00
7 changed files with 32 additions and 32 deletions

No files matched your search

@@ -2,17 +2,17 @@ package com.gtnewhorizons.angelica.common;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
/**
* This Block is not actually getting registered. A static instance is created in AngelicaMod.
* In order to register the texture for it, there is a mixin to TextureMap which injects a call
* to this instance's registerBlocKIcons method. Actually registering the block on the client but
* not the server can cause block IDs to different between client/server, which is not good.
* Actually registering the block on the client but not the server can cause block IDs to
* different between client/server, which is not good.
* We're essentially injecting the block's texture, so that we may use this block as if it were
* any normal block for rendering purposes with RenderBlocks and such, but not have to actually
@@ -25,21 +25,24 @@ public class BlockError extends Block {
public BlockError() {
super(Material.rock);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg)
{
for (int i = 0; i < icons.length; i++) {
icons[i] = reg.registerIcon("angelica:error_block_" + i);
public void onTextureStitch(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
for (int i = 0; i < icons.length; i++) {
icons[i] = event.map.registerIcon("angelica:error_block_" + i);
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icons[meta];
return meta >= 0 && meta < icons.length ? icons[meta] : null;
}
}
@@ -971,6 +971,20 @@ public class GLStateManager {
GL11.glDrawBuffer(mode);
}
public static void glDrawElements(int mode, IntBuffer indices) {
if(AngelicaConfig.enableIris) {
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
}
GL11.glDrawElements(mode, indices);
}
public static void glBegin(int mode) {
if (AngelicaConfig.enableIris) {
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
}
GL11.glBegin(mode);
}
public static void glLogicOp(int opcode) {
GL11.glLogicOp(opcode);
}
@@ -29,7 +29,6 @@ public enum Mixins {
,"angelica.MixinMinecraft"
,"angelica.optimizations.MixinRendererLivingEntity"
,"angelica.MixinFMLClientHandler"
,"angelica.MixinTextureMap"
)
),
ANGELICA_VBO(
@@ -97,6 +97,7 @@ public class RedirectorTransformer implements IClassTransformer {
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_SCISSOR_TEST, "ScissorTest");
methodRedirects.put(GL11, RedirectMap.newMap()
.add("glAlphaFunc")
.add("glBegin")
.add("glBindTexture")
.add("glBlendFunc")
.add("glCallList")
@@ -119,6 +120,7 @@ public class RedirectorTransformer implements IClassTransformer {
.add("glDepthRange")
.add("glDrawArrays")
.add("glDrawBuffer")
.add("glDrawElements")
.add("glEdgeFlag")
.add("glEndList")
.add("glFog")
@@ -1,18 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.angelica;
import com.gtnewhorizons.angelica.AngelicaMod;
import net.minecraft.client.renderer.texture.TextureMap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TextureMap.class)
public class MixinTextureMap {
@Inject(method = "registerIcons", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getMinecraft()Lnet/minecraft/client/Minecraft;"))
private void angelica$registerErrorBlockIcon(CallbackInfo ci) {
TextureMap thisObject = (TextureMap)(Object)this;
AngelicaMod.blockError.registerBlockIcons(thisObject);
}
}
@@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class MixinEntityRenderer implements IResourceManagerReloadListener {
@Shadow public Minecraft mc;
@Inject(at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glClear(I)V", shift = At.Shift.AFTER, ordinal = 0), method = "renderWorld(FJ)V", remap = false)
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/culling/ClippingHelperImpl;getInstance()Lnet/minecraft/client/renderer/culling/ClippingHelper;", shift = At.Shift.AFTER, ordinal = 0), method = "renderWorld(FJ)V")
private void iris$beginRender(float partialTicks, long startTime, CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
CapturedRenderingState.INSTANCE.setTickDelta(partialTicks);
SystemTimeUniforms.COUNTER.beginFrame();
@@ -24,7 +24,7 @@ public class MixinRendererLivingEntity {
final float r = (j >> 16 & 255) / 255.0F;
final float g = (j >> 8 & 255) / 255.0F;
final float b = (j & 255) / 255.0F;
CapturedRenderingState.INSTANCE.setCurrentEntityColor(r, g, b, 1.0F - a);
CapturedRenderingState.INSTANCE.setCurrentEntityColor(r, g, b, a);
return j;
}