mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-23 21:59:44 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14b7178419 | ||
|
|
22bf48c093 | ||
|
|
4600bca2d0 | ||
|
|
fcb9536d93 | ||
|
|
51a6a72ae5 |
No files matched your search
@@ -3,6 +3,8 @@ package com.gtnewhorizons.angelica.hudcaching;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
@@ -27,16 +29,14 @@ import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
// See LICENSE+HUDCaching.md for license information.
|
||||
|
||||
public class HUDCaching {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
public static Framebuffer framebuffer;
|
||||
static {
|
||||
framebuffer = new Framebuffer(0, 0, true);
|
||||
framebuffer.setFramebufferColor(0, 0, 0, 0);
|
||||
}
|
||||
private static boolean dirty = true;
|
||||
|
||||
public static boolean renderingCacheOverride;
|
||||
@@ -63,9 +63,13 @@ public class HUDCaching {
|
||||
|
||||
private final List<Long> updateTimeList = new ArrayList<>(21);
|
||||
private static boolean isEnabled = true;
|
||||
private static final KeyBinding toggle = new KeyBinding("Toggle HUDCaching", 0, "Debug");
|
||||
|
||||
// moved initialization to when its registered to avoid an empty Debug category, which can cause crashes when
|
||||
// opening the controls menu and hudcaching is disabled in the config
|
||||
private static KeyBinding toggle;
|
||||
|
||||
public static void registerKeyBindings() {
|
||||
toggle = new KeyBinding("Toggle HUDCaching", 0, "Debug");
|
||||
ClientRegistry.registerKeyBinding(toggle);
|
||||
}
|
||||
|
||||
@@ -86,7 +90,7 @@ public class HUDCaching {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeypress(InputEvent.KeyInputEvent event) {
|
||||
if (toggle.isPressed()) {
|
||||
if (toggle != null && toggle.isPressed()) {
|
||||
isEnabled = !isEnabled;
|
||||
final String msg = isEnabled ? "Enabled HUDCaching" : "Disabled HUDCaching";
|
||||
if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText(msg));
|
||||
@@ -102,10 +106,20 @@ public class HUDCaching {
|
||||
}
|
||||
}
|
||||
|
||||
// highest so it runs before the GLSM load event
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onJoinWorld(WorldEvent.Load event) {
|
||||
if (event.world.isRemote){
|
||||
LOGGER.info("World loaded - Initializing HUDCaching");
|
||||
HUDCaching.framebuffer = new Framebuffer(0, 0, true);
|
||||
HUDCaching.framebuffer.setFramebufferColor(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void renderCachedHud(EntityRenderer renderer, GuiIngame ingame, float partialTicks, boolean hasScreen, int mouseX, int mouseY) {
|
||||
|
||||
if (!OpenGlHelper.isFramebufferEnabled() || !isEnabled) {
|
||||
if (!OpenGlHelper.isFramebufferEnabled() || !isEnabled || framebuffer == null) {
|
||||
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
|
||||
+5
@@ -18,4 +18,9 @@ public class MixinChunkCache implements ITexturesCache {
|
||||
public HashSet<IIcon> getRenderedTextures() {
|
||||
return renderedIcons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableTextureTracking() {
|
||||
|
||||
}
|
||||
}
|
||||
+18
-7
@@ -2,7 +2,7 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.animation;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFire;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -27,7 +27,8 @@ public class MixinRenderBlocks implements ITexturesCache {
|
||||
@Shadow
|
||||
public IIcon overrideBlockTexture;
|
||||
|
||||
private Set<IIcon> renderedSprites = new ObjectOpenHashSet<>();
|
||||
private Set<IIcon> renderedSprites = new ReferenceOpenHashSet<>();
|
||||
private boolean enableSpriteTracking;
|
||||
|
||||
/**
|
||||
* @author laetansky Here where things get very tricky. We can't just mark blocks textures for update because this
|
||||
@@ -46,14 +47,17 @@ public class MixinRenderBlocks implements ITexturesCache {
|
||||
|
||||
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
|
||||
|
||||
this.renderedSprites.add(icon);
|
||||
if(this.enableSpriteTracking)
|
||||
this.renderedSprites.add(icon);
|
||||
}
|
||||
|
||||
@Inject(method = "renderBlockFire", at = @At("HEAD"))
|
||||
public void angelica$markFireBlockAnimationForUpdate(BlockFire instance, int x, int y, int z,
|
||||
CallbackInfoReturnable<Boolean> cir) {
|
||||
this.renderedSprites.add(instance.getFireIcon(0));
|
||||
this.renderedSprites.add(instance.getFireIcon(1));
|
||||
if(this.enableSpriteTracking) {
|
||||
this.renderedSprites.add(instance.getFireIcon(0));
|
||||
this.renderedSprites.add(instance.getFireIcon(1));
|
||||
}
|
||||
AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(0), blockAccess);
|
||||
AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(1), blockAccess);
|
||||
}
|
||||
@@ -62,7 +66,8 @@ public class MixinRenderBlocks implements ITexturesCache {
|
||||
public IIcon angelica$markFluidAnimationForUpdate(IIcon icon) {
|
||||
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
|
||||
|
||||
this.renderedSprites.add(icon);
|
||||
if(this.enableSpriteTracking)
|
||||
this.renderedSprites.add(icon);
|
||||
|
||||
return icon;
|
||||
}
|
||||
@@ -72,11 +77,17 @@ public class MixinRenderBlocks implements ITexturesCache {
|
||||
CallbackInfo ci) {
|
||||
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
|
||||
|
||||
this.renderedSprites.add(icon);
|
||||
if(this.enableSpriteTracking)
|
||||
this.renderedSprites.add(icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IIcon> getRenderedTextures() {
|
||||
return renderedSprites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableTextureTracking() {
|
||||
enableSpriteTracking = true;
|
||||
}
|
||||
}
|
||||
+6
@@ -26,6 +26,7 @@ public class MixinWorldRenderer implements ITexturesCache {
|
||||
|
||||
@ModifyArg(method = "updateRenderer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;<init>(Lnet/minecraft/world/IBlockAccess;)V"))
|
||||
private IBlockAccess angelica$onUpdateRenderer(IBlockAccess chunkCache) {
|
||||
((ITexturesCache) chunkCache).enableTextureTracking();
|
||||
renderedIcons = ((ITexturesCache) chunkCache).getRenderedTextures();
|
||||
return chunkCache;
|
||||
}
|
||||
@@ -43,4 +44,9 @@ public class MixinWorldRenderer implements ITexturesCache {
|
||||
public Set<IIcon> getRenderedTextures() {
|
||||
return renderedIcons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableTextureTracking() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,5 @@ import java.util.Set;
|
||||
public interface ITexturesCache {
|
||||
|
||||
Set<IIcon> getRenderedTextures();
|
||||
void enableTextureTracking();
|
||||
}
|
||||
@@ -276,7 +276,8 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
// This is a bit of a hack to prevent the FOV from being modified by other mods
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onFOVModifierUpdate(FOVUpdateEvent event) {
|
||||
if (!(boolean)Settings.DYNAMIC_FOV.option.getStore()){
|
||||
event.newfov = 1.0F;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AngelicaBlockSafetyRegistry {
|
||||
&& (isbrh.getClass().isAnnotationPresent(ThreadSafeISBRH.class)
|
||||
|| isbrh instanceof ThreadSafeISBRHFactory);
|
||||
} else {
|
||||
canBeOffThread = !(block.getClass().getName().startsWith("gregtech.")) && !(block.getClass().getName().startsWith("com.github.bartimaeusnek."));
|
||||
canBeOffThread = !(block.getClass().getName().startsWith("com.github.bartimaeusnek."));
|
||||
}
|
||||
|
||||
final long stamp = LOCK.writeLock();
|
||||
|
||||
+2
@@ -116,6 +116,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
final WorldSlice slice = cache.getWorldSlice();
|
||||
final RenderBlocks renderBlocks = new RenderBlocks(slice);
|
||||
if(renderBlocks instanceof ITexturesCache) ((ITexturesCache)renderBlocks).enableTextureTracking();
|
||||
|
||||
final int baseX = this.render.getOriginX();
|
||||
final int baseY = this.render.getOriginY();
|
||||
@@ -246,6 +247,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
final BlockPosImpl renderOffset = this.offset;
|
||||
final RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
if(rb instanceof ITexturesCache) ((ITexturesCache)rb).enableTextureTracking();
|
||||
while(!mainThreadBlocks.isEmpty()) {
|
||||
final long longPos = mainThreadBlocks.dequeueLong();
|
||||
if (cancellationSource.isCancelled()) {
|
||||
|
||||
Reference in new issue
Block a user