mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 12:52:19 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f233ba65e3 | ||
|
|
c0d636d4f7 | ||
|
|
bd5cd350c3 | ||
|
|
88936d3713 | ||
|
|
cf5bf2e2e7 | ||
|
|
cfd2388c85 |
No files matched your search
@@ -4,13 +4,15 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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
|
||||
@@ -19,15 +21,28 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class BlockError extends Block {
|
||||
|
||||
public static final IIcon[] icons = new IIcon[2];
|
||||
|
||||
public BlockError() {
|
||||
super(Material.rock);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
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 void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
this.blockIcon = reg.registerIcon("angelica:error_block");
|
||||
public IIcon getIcon(int side, int 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")
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
@@ -15,7 +15,9 @@ options.cloud_height.tooltip=Cloud Elevation
|
||||
options.cloud_scale=Cloud Scale
|
||||
options.cloud_scale.tooltip=Cloud Scale
|
||||
options.gui_background=Background
|
||||
options.gui_background.tooltip=Background
|
||||
options.downfall_distance=Weather Effects
|
||||
options.downfall_distance.tooltip=Weather Effects
|
||||
options.dynamic_fov=Dynamic FOV
|
||||
options.dynamic_fov.tooltip=If enabled, the game's field of view will change based on the player's speed.
|
||||
options.fog_near_distance=Near Fog Distance
|
||||
@@ -31,10 +33,13 @@ options.mode_glint_inv.tooltip=GUI Enchant VFX
|
||||
options.mode_glint_world=World Enchant VFX
|
||||
options.mode_glint_world.tooltip=World Enchant VFX
|
||||
options.mode_gui_background=Menu Backgrounds
|
||||
options.mode_gui_background.tooltip=Menu Backgrounds
|
||||
options.mode_leaves=Foliage
|
||||
options.mode_leaves.tooltip=Foliage
|
||||
options.mode_light_flicker=Light Flicker
|
||||
options.mode_light_flicker.tooltip=Light Flicker
|
||||
options.mode_shadows=Entity Shadows
|
||||
options.mode_shadows.tooltip=Entity Shadows
|
||||
options.mode_sky=Sky
|
||||
options.mode_sky.tooltip=Render the Sky
|
||||
options.mode_sun_moon=Sun & Moon
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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();
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+36
-12
@@ -1,8 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -19,6 +23,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(RenderBlocks.class)
|
||||
public abstract class MixinRenderBlocks {
|
||||
|
||||
@Unique
|
||||
private static final ObjectOpenHashSet<String> isbrhExceptionCache = new ObjectOpenHashSet<>();
|
||||
|
||||
@Unique
|
||||
private static final Object2IntOpenHashMap<Class<? extends Exception>> exceptionErrorBlockMap = new Object2IntOpenHashMap<>();
|
||||
|
||||
static {
|
||||
exceptionErrorBlockMap.put(NullPointerException.class, 0);
|
||||
exceptionErrorBlockMap.put(ArrayIndexOutOfBoundsException.class, 1);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean isRenderingByType = false;
|
||||
|
||||
@@ -54,12 +69,7 @@ public abstract class MixinRenderBlocks {
|
||||
expect = 0
|
||||
)
|
||||
private boolean wrapRenderWorldBlockObfuscated(RenderBlocks rb, IBlockAccess world, int x, int y, int z, Block block, int modelId) {
|
||||
try {
|
||||
return RenderingRegistry.instance().renderWorldBlock(rb, world, x, y, z, block, modelId);
|
||||
} catch (NullPointerException ignored) {
|
||||
rb.renderStandardBlock(AngelicaMod.blockError, x, y, z);
|
||||
}
|
||||
return false;
|
||||
return handleISBRHException(rb, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
@@ -72,12 +82,7 @@ public abstract class MixinRenderBlocks {
|
||||
expect = 0
|
||||
)
|
||||
private boolean wrapRenderWorldBlockDeobfuscated(RenderBlocks rb, IBlockAccess world, int x, int y, int z, Block block, int modelId) {
|
||||
try {
|
||||
return RenderingRegistry.instance().renderWorldBlock(rb, world, x, y, z, block, modelId);
|
||||
} catch (NullPointerException ignored) {
|
||||
rb.renderStandardBlock(AngelicaMod.blockError, x, y, z);
|
||||
}
|
||||
return false;
|
||||
return handleISBRHException(rb, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderStandardBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isAmbientOcclusionEnabled()Z"))
|
||||
@@ -89,4 +94,23 @@ public abstract class MixinRenderBlocks {
|
||||
|
||||
return Minecraft.isAmbientOcclusionEnabled();
|
||||
}
|
||||
|
||||
private boolean handleISBRHException(RenderBlocks rb, IBlockAccess world, int x, int y, int z, Block block, int modelId) {
|
||||
try {
|
||||
return RenderingRegistry.instance().renderWorldBlock(rb, world, x, y, z, block, modelId);
|
||||
} catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
|
||||
// Render Error Block
|
||||
int meta = exceptionErrorBlockMap.getOrDefault(e.getClass(), 0);
|
||||
rb.overrideBlockTexture = BlockError.icons[exceptionErrorBlockMap.getOrDefault(e.getClass(), 0)];
|
||||
rb.renderStandardBlock(AngelicaMod.blockError, x, y, z);
|
||||
rb.overrideBlockTexture = null;
|
||||
|
||||
// Check if we've already caught the exception for this block and log it if we haven't
|
||||
String key = block.getUnlocalizedName() + ":" + meta;
|
||||
if (isbrhExceptionCache.add(key)) {
|
||||
AngelicaTweaker.LOGGER.warn("Caught an exception during ISBRH rendering for {} at position {}, {}, {} with renderer ID {}", block.getUnlocalizedName(), x, y, z, modelId, e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user