Compare commits

...
Author SHA1 Message Date
ev chang 7e4292bdba Add HUDCaching FPS (from PolyPatcher) 2024-07-12 10:49:07 -07:00
Darren Eberly f79e112700 More GLSM Lighting Fixes (#554) 2024-07-11 15:16:15 -04:00
Darren Eberly ba46feb20b GLSM Lighting (#553) 2024-07-11 11:10:04 -04:00
Jason Mitchell 33804c67da Use gtnhlib for coordinate packing/unpacking (#550) 2024-07-07 22:48:58 -07:00
Caedis 3c9353e143 Update dynamic lights from beta branch (#534)
* move dynamic lights lang to angelica

* No light when in water

* update bs

* add battlegear2 compat

Can't add backhand compat since it shares api package path with
battlegear2 (mods/battlegear2/api/core/BattlegearUtils)

* Add backhand 1.4.1+ support
2024-06-26 05:39:26 -07:00
JL2210 77eb3ad46a Fix NPE from MineFactory Reloaded during lag spikes (#522)
* Fix NPE from MineFactory Reloaded during lag spikes

This is an ARR mod and hence cannot be forked.
I decided to put the fix here rather than e.g. Hodgepodge as this is only an
issue with Angelica and seems to be due to its thread safety patches.

* Rewrite as injector

IDE go brr
2024-06-24 17:45:37 -07:00
FalsePattern 8a56ab8ca1 fixed crash with EndlessIDs when joining a multiplayer server 2024-06-09 21:24:26 +08:00
Dakotah fe065803aa THIS ADDS FEATURE REQUEST ISSUE TO GITHUB (#514)
* Add feature request template

* Add feature request template

* Add labels to feature request template automatically

* switch labels to enhancement
2024-05-30 16:30:09 -07:00
ah-OOG-ah f94268c384 Add null check to FluidRenderer (#513)
* Add null check to FluidRenderer

* Update FluidRenderer.java
2024-05-30 17:56:32 -04:00
jss2a98aj f7a8b0f3bf Cloud scaling, distance, and some fixes 2024-05-24 22:16:41 -07:00
embeddedt 8893cf2291 Mark chunk graph as dirty when FOV changes (#506) 2024-05-24 15:59:46 -04:00
Jason Mitchell adc575c5ab remaps 2024-05-23 20:00:21 -07:00
Jason Mitchell 35a056b73b Patches vanilla getFlowDirection to not crash with a ClassCastException if another mod implements their own fluid renderer and calls getFlowDirection when COFH ASM is loaded 2024-05-23 20:00:21 -07:00
jss2a98aj fbbb0ed4f2 Various cleanup (IJK -> XYZ etc) 2024-05-23 19:49:49 -07:00
jss2a98aj bc148ba09c Updated file overlooked in previous sync 2024-05-23 19:49:49 -07:00
jss2a98aj 1db3932af0 Roll ITileOverride into TileOverride 2024-05-23 19:49:49 -07:00
jss2a98aj 0fd4611a97 Refactor glass pane mixins to solve compat issues 2024-05-23 19:49:49 -07:00
jss2a98aj 27243991b7 Add near fog distance percentage slider
Initial commit by MellowArpeggiation and George Paton
FOG_NEAR to FOG_NEAR_DISTANCE, minimum of 1% by jss2a98aj
2024-05-23 19:49:49 -07:00
jss2a98aj 956eec0366 Face culling for the Enchantment Table 2024-05-23 19:49:49 -07:00
jss2a98aj 9b06c5a210 Add interpolated icon support (Roadhog360) 2024-05-23 19:49:49 -07:00
jss2a98aj 5511759b6d Fix door smooth lighting, cull sides against solid blocks 2024-05-23 19:49:49 -07:00
jss2a98aj fb5aa81e01 Sandstone connected textures 2024-05-23 19:49:49 -07:00
jss2a98aj 6592e13e02 Improve Bookshelf connected textures 2024-05-23 19:49:49 -07:00
Jason Mitchell 31174dc35a Update README.MD 2024-05-23 17:57:46 -07:00
Caedis f0bd9de081 Disable Dynamic Lights video option when module is disabled (#491) 2024-05-17 20:18:23 +00:00
Jason Mitchell 75617a5456 More null checks 2024-05-14 23:23:01 -07:00
Jason Mitchell e158faada0 Only set/access texture info cache from the main thread 2024-05-14 22:35:21 -07:00
Raven Szewczyk f684bc0a1b Fix RenderBlockFluid reading the block type from the world access multiple times (#482)
* Fix RenderBlockFluid reading the block type from the world access multiple times

* Fix compiler warnings
2024-05-13 18:04:58 +01:00
Jason Mitchell 3d56b1c2fc Make TextureInfoCache safer 2024-05-12 09:35:43 -07:00
Jason Mitchell 6e60f671b5 Neuter FML optifine detection/reporting 2024-05-11 10:33:45 -07:00
Caedis 323d2e726c Adjust dynamic lights in World#getLightBrightnessForSkyBlocks as well (#466)
This can be called when rendering is done on the main there as
WorldSlice is only used outside the main thread.
2024-05-06 08:50:25 -07:00
88d5030aa9 Add Dynamic Lights to Alpha (Module Off, Lights Off) (#465)
If a player is reading this and wants dynamic lights during alpha, please enable the module in the angelica-modules config file then the config option in the video settings will take effect.

* Implement Dynamic Lights (#360)

* inital dynamicLights

* continue work

* Add credit

* More implementations

* "Working"

* NotFine 0.2.2 sync (#462)

* Slight cleanup in ColorizeBlock

* Don't call System.gc

* Add toggle for Renderpass (forced to false)

* Dont rebuild the same chunk 8 times

* Use client pos

* Fully working + configs

* Clean up

* Fix readme and gradle properties

* Fix tooltip

* nit changes

---------

Co-authored-by: jss2a98aj <[email protected]>

* Might help if the dynamic lights mixins follow the config setting

* Fix shadows from showing on sides of blocks

* Set dynamic lights module to off for alpha

* Add missed enable checks

---------

Co-authored-by: jss2a98aj <[email protected]>
Co-authored-by: Jason Mitchell <[email protected]>
2024-05-06 00:19:50 +00:00
jss2a98aj 894b9573db Natura + Tinker's Construct berry bush leaf mode support 2024-05-05 13:42:36 -07:00
jss2a98aj d8d8cd93c5 Leaf render mode edge case handling 2024-05-05 13:42:36 -07:00
jss2a98aj 986f1bd6a1 NotFine 0.2.2 sync (#462)
* Slight cleanup in ColorizeBlock

* Don't call System.gc

* Add toggle for Renderpass (forced to false)
2024-05-03 23:54:02 -04:00
jss2a98aj e85ca85027 Small NotFine style settings menu fix (#457)
* Fix allowToggle3DAnaglyph

* Remove unused import
2024-05-01 07:26:18 -07:00
Raven Szewczyk d96023f36c Fix FontRenderer intel issue (#456) 2024-04-30 17:55:03 +00:00
Jason Mitchell 203b552993 Attempt at BetterCrashes Compat
- clean up the CapturingTessellator
- clean up GLStateManager
2024-04-29 10:50:56 -07:00
Jason Mitchell 96e2f42251 Update Mixins.java (#447)
Move some Notfine guarded mixins to enableMCPatcherForgeFeatures
2024-04-28 15:06:23 -07:00
115 changed files with 3491 additions and 1352 deletions

No files matched your search

@@ -0,0 +1,33 @@
name: Feature Request
description: "Request a feature."
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: "Please use this form to request features. We ask you check if it was already requested though"
- type: input
id: discord
attributes:
label: Your GTNH Discord Username
description: Leave empty if you don't have one, but this will make it harder to contact you if we need additional info.
placeholder: "Example: Wumpus#1234"
- type: textarea
id: request
attributes:
label: Feature Request
description: "Relevant information, as well as relevant images"
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
validations:
required: true
- type: checkboxes
id: final
attributes:
label: Final Checklist
description: Certify that you read things
options:
- label: "I have searched the issues and haven't found a similar issue."
required: true
- label: "I have read the known incompatibilities and this is not related to one of those."
required: true
- label: "This issue is not related to a feature that is disabed by default - Shaders, MCPF, etc. [They'll be enabled when they're ready for testing]"
required: true
+1
View File
@@ -1,6 +1,7 @@
.gradle
.settings
/.idea/
/.vs/
/.vscode/
/run/
/build/
+10 -5
View File
@@ -11,16 +11,18 @@
# Required Dependencies
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.2.9
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.3.2
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
# Known (temporary) Incompatibilities
* Forge Relocation - Currently non Thread Safe; safe if not in use
* ProjectRed Frames - Currently non Thread Safe; safe if not in use
* EndlessIDs - Future compat planned
* FalseTweaks - Future compat planned
* SmoothFont - Future compat planned
* RPLE - Future compat planned
# Known - Incompatibilities
* EndlessIDs - Not currently planned (Looking for volunteers)
* FalseTweaks - Not currently planned (Looking for volunteers)
* SmoothFont - Not currently planned (Looking for volunteers)
* RPLE - Not currently planned (Looking for volunteers)
# Permanent Incompatibilities
* Optifine [Disabled, won't fix]
@@ -65,3 +67,6 @@
* FRAPI and Indigo
* Model building API heavily inspired by/copied from Fabric's; upstream may use it under the original Apache 2.0
license, see LICENSE in `com.gtnewhorizons.angelica.models`
* Dynamic Lights
* LambdAurora for [LambDynamicLights](https://github.com/LambdAurora/LambDynamicLights) under the MIT license, and the Forge port anthxnymc for [DynamicLightsReforged](https://github.com/anthxnymc/DynamicLightsReforged), also under the MIT license
+13 -3
View File
@@ -58,7 +58,7 @@ dependencies {
// Iris Shaders
compileOnly('org.jetbrains:annotations:24.0.1')
api("com.github.GTNewHorizons:GTNHLib:0.2.9:dev")
api("com.github.GTNewHorizons:GTNHLib:0.3.2:dev")
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
implementation("io.github.douira:glsl-transformer:1.0.0")
shadowImplementation("io.github.douira:glsl-transformer:1.0.0") { // glsl-transformer Noncommercial License 1.0.0
@@ -75,13 +75,20 @@ dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
compileOnly("com.github.GTNewHorizons:twilightforest:2.5.16:dev") { transitive = false }
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.0-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Natura:2.6.1:dev")
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api") { transitive = false }
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0002:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false }
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false }
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0003:dev") { transitive = false }
compileOnly(rfg.deobf("curse.maven:extrautils-225561:2264383"))
compileOnly(rfg.deobf("curse.maven:dynamiclights-227874:2337326"))
compileOnly("curse.maven:minefactory-reloaded-66672:2277486")
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.0.3:dev") // Mixin Version
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
@@ -97,6 +104,9 @@ dependencies {
// Hodgepodge
transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
// Better Crashes
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
// Tests
testImplementation(platform('org.junit:junit-bom:5.9.2'))
+1 -1
View File
@@ -16,5 +16,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.21'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
}
@@ -15,7 +15,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
name = "Angelica",
version = Tags.VERSION,
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.2.9,);",
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.3.2,);",
acceptedMinecraftVersions = "[1.7.10]",
acceptableRemoteVersions = "*",
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
@@ -1,24 +1,10 @@
package com.gtnewhorizons.angelica.api;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
import java.math.RoundingMode;
import static com.google.common.math.IntMath.log2;
public interface BlockPos {
int SIZE_BITS_X = 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY);
int SIZE_BITS_Z = SIZE_BITS_X;
int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z;
long BITS_X = (1L << SIZE_BITS_X) - 1L;
long BITS_Y = (1L << SIZE_BITS_Y) - 1L;
long BITS_Z = (1L << SIZE_BITS_Z) - 1L;
int BIT_SHIFT_Z = SIZE_BITS_Y;
int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z;
int getX();
int getY();
int getZ();
@@ -28,22 +14,6 @@ public interface BlockPos {
long asLong();
static long asLong(int x, int y, int z) {
long l = 0L;
l |= ((long) x & BITS_X) << BIT_SHIFT_X;
l |= ((long) y & BITS_Y) << 0;
l |= ((long) z & BITS_Z) << BIT_SHIFT_Z;
return l;
}
public static int unpackLongX(long packedPos) {
return (int)(packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X);
}
public static int unpackLongY(long packedPos) {
return (int)(packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y);
}
public static int unpackLongZ(long packedPos) {
return (int)(packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z);
return CoordinatePacker.pack(x, y, z);
}
}
@@ -258,7 +258,6 @@ public class BatchingFontRenderer {
GLStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
GLStateManager.glShadeModel(GL_FLAT);
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
glTexCoordPointer(2, 0, batchVtxTexCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, batchVtxColors);
@@ -289,7 +288,9 @@ public class BatchingFontRenderer {
glDrawElements(GL_TRIANGLES, batchIndices);
}
glPopClientAttrib();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if (isTextureEnabledBefore) {
GLStateManager.glEnable(GL11.GL_TEXTURE_2D);
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import net.dries007.holoInventory.HoloInventory;
import xonin.backhand.Backhand;
public class ModStatus {
/**
@@ -16,14 +17,18 @@ public class ModStatus {
*/
public static boolean isOldNEIDLoaded;
public static boolean isBetterCrashesLoaded;
public static boolean isNEIDMetadataExtended;
public static boolean isLotrLoaded;
public static boolean isChunkAPILoaded;
public static boolean isEIDBiomeLoaded;
public static boolean isXaerosMinimapLoaded;
public static boolean isHoloInventoryLoaded;
public static boolean isBattlegearLoaded;
public static boolean isBackhandLoaded;
public static void preInit(){
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
isNEIDLoaded = Loader.isModLoaded("neid");
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
isLotrLoaded = Loader.isModLoaded("lotr");
@@ -31,6 +36,8 @@ public class ModStatus {
isEIDBiomeLoaded = Loader.isModLoaded("endlessids_biome");
isXaerosMinimapLoaded = Loader.isModLoaded("XaeroMinimap");
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
isBattlegearLoaded = Loader.isModLoaded("battlegear2");
isBackhandLoaded = Loader.isModLoaded("backhand");
if (isHoloInventoryLoaded){
isHoloInventoryLoaded = new DefaultArtifactVersion("2.4.4-GTNH")
@@ -39,6 +46,13 @@ public class ModStatus {
) <= 0;
}
if (isBackhandLoaded){
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
.compareTo(
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
) <= 0;
}
isNEIDMetadataExtended = false;
if (isNEIDLoaded) {
@@ -0,0 +1,34 @@
package com.gtnewhorizons.angelica.compat.bettercrashes;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
import cpw.mods.fml.common.Optional;
import net.minecraft.client.Minecraft;
import vfyjxf.bettercrashes.utils.StateManager;
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
@Optional.Interface(modid = "angelica", iface = "vfyjxf.bettercrashes.utils.StateManager.IResettable")
public class BetterCrashesCompat implements StateManager.IResettable {
private static BetterCrashesCompat INSTANCE;
public static void init() {
if (INSTANCE == null) {
INSTANCE = new BetterCrashesCompat();
}
}
public BetterCrashesCompat() {
LOGGER.info("BetterCrashesCompat initialized");
this.register();
}
@Override
public void resetState() {
LOGGER.info("Reloading SodiumRenderer");
((IRenderGlobalExt) Minecraft.getMinecraft().renderGlobal).reload();
LOGGER.info("Resetting GLStateManager");
GLStateManager.reset();
}
}
@@ -0,0 +1,37 @@
package com.gtnewhorizons.angelica.compat.endlessids;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import net.minecraft.world.chunk.Chunk;
import static com.falsepattern.endlessids.constants.ExtendedConstants.biomeIDMask;
import static com.falsepattern.endlessids.constants.ExtendedConstants.biomeIDNull;
public class EndlessIDsCompat {
public static void sodium$populateBiomes(Chunk chunk) {
if (!(chunk instanceof ChunkBiomeHook hook))
return;
val biomes = hook.getBiomeShortArray();
if (biomes == null)
return;
val cX = chunk.xPosition << 4;
val cZ = chunk.zPosition << 4;
val manager = chunk.worldObj.getWorldChunkManager();
for(var z = 0; z < 16; z++) {
for(var x = 0; x < 16; x++) {
val idx = (z << 4) + x;
val biome = biomes[idx] & biomeIDMask;
if(biome == biomeIDNull) {
val generated = manager.getBiomeGenAt(cX + x, cZ + z);
if (generated == null)
continue;
biomes[idx] = (short)(generated.biomeID & biomeIDMask);
}
}
}
}
}
@@ -1,14 +1,11 @@
package com.gtnewhorizons.angelica.compat.mojang;
import com.gtnewhorizons.angelica.api.BlockPos;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.api.MutableBlockPos;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.common.util.ForgeDirection;
import org.joml.Vector3i;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongX;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongY;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongZ;
// Should we keep this?
public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@@ -54,7 +51,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@Override
public long asLong() {
return BlockPos.asLong(this.x, this.y, this.z);
return CoordinatePacker.pack(this.x, this.y, this.z);
}
@Override
@@ -65,6 +62,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@Override
public BlockPosImpl set(long packedPos) {
return set(unpackLongX(packedPos), unpackLongY(packedPos), unpackLongZ(packedPos));
CoordinatePacker.unpack(packedPos, this);
return this;
}
}
@@ -70,17 +70,26 @@ public class AngelicaConfig {
@Config.DefaultBoolean(true)
public static boolean showSplashMemoryBar;
@Config.Comment("Renders the HUD elements once per tick and reuses the pixels to improve performance. [Experimental]")
@Config.Comment("Renders the HUD elements once per 20 frames (by default) and reuses the pixels to improve performance. [Experimental]")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableHudCaching;
@Config.Comment("The amount of frames to wait before updating the HUD elements. [Experimental]")
@Config.DefaultInt(20)
@Config.RangeInt(min = 1, max = 60)
public static int hudCachingFPS = 20;
@Config.Comment("Batch drawScreen fonts [Experimental]")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableFontRenderer;
@Config.Comment("Enable Dynamic Lights")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
public static boolean enableDynamicLights;
@Config.Comment("Optimize world update light. [From Hodgepodge]")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
@@ -106,6 +115,16 @@ public class AngelicaConfig {
@Config.RequiresMcRestart
public static boolean fixExtraUtilsSodiumCompat;
@Config.Comment("Fix thread-safety issues in MineFactory Reloaded")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixMineFactoryReloadedSodiumCompat;
@Config.Comment("Fix RenderBlockFluid reading the block type from the world access multiple times")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixFluidRendererCheckingBlockAgain;
@Config.Comment("Enable Debug Logging")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
@@ -0,0 +1,390 @@
package com.gtnewhorizons.angelica.dynamiclights;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import mods.battlegear2.api.core.IBattlePlayer;
import mods.battlegear2.api.core.IInventoryPlayerBattle;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xonin.backhand.api.core.BackhandUtils;
import xonin.backhand.api.core.IBackhandPlayer;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Predicate;
public class DynamicLights {
private static DynamicLights instance;
public static DynamicLightsMode Mode = DynamicLightsMode.OFF;
private static final double MAX_RADIUS = 7.75;
private static final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;
private final Set<IDynamicLightSource> dynamicLightSources = new ObjectOpenHashSet<>();
private final ReentrantReadWriteLock lightSourcesLock = new ReentrantReadWriteLock();
private long lastUpdate = System.currentTimeMillis();
private int lastUpdateCount = 0;
public static DynamicLights get() {
if (instance == null)
instance = new DynamicLights();
return instance;
}
public static boolean isEnabled() {
return Mode.isEnabled() && AngelicaConfig.enableDynamicLights;
}
/**
* Updates all light sources.
*
* @param renderer the renderer
*/
public void updateAll(@NotNull SodiumWorldRenderer renderer) {
if (!isEnabled())
return;
long now = System.currentTimeMillis();
if (now >= this.lastUpdate + 50) {
this.lastUpdate = now;
this.lastUpdateCount = 0;
this.lightSourcesLock.readLock().lock();
for (var lightSource : this.dynamicLightSources) {
if (lightSource.angelica$updateDynamicLight(renderer))
this.lastUpdateCount++;
}
this.lightSourcesLock.readLock().unlock();
}
}
public int getLastUpdateCount() {
return this.lastUpdateCount;
}
public void addLightSource(IDynamicLightSource lightSource) {
this.lightSourcesLock.writeLock().lock();
this.dynamicLightSources.add(lightSource);
this.lightSourcesLock.writeLock().unlock();
}
/**
* Removes the light source from the tracked light sources.
*
* @param lightSource the light source to remove
*/
public void removeLightSource(@NotNull IDynamicLightSource lightSource) {
this.lightSourcesLock.writeLock().lock();
var dynamicLightSources = this.dynamicLightSources.iterator();
IDynamicLightSource it;
while (dynamicLightSources.hasNext()) {
it = dynamicLightSources.next();
if (it.equals(lightSource)) {
dynamicLightSources.remove();
if (SodiumWorldRenderer.getInstance() != null)
lightSource.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
break;
}
}
this.lightSourcesLock.writeLock().unlock();
}
/**
* Removes light sources if the filter matches.
*
* @param filter the removal filter
*/
public void removeLightSources(@NotNull Predicate<IDynamicLightSource> filter) {
this.lightSourcesLock.writeLock().lock();
var dynamicLightSources = this.dynamicLightSources.iterator();
IDynamicLightSource it;
while (dynamicLightSources.hasNext()) {
it = dynamicLightSources.next();
if (filter.test(it)) {
dynamicLightSources.remove();
if (SodiumWorldRenderer.getInstance() != null) {
if (it.angelica$getLuminance() > 0)
it.angelica$resetDynamicLight();
it.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
}
break;
}
}
this.lightSourcesLock.writeLock().unlock();
}
/**
* Clears light sources.
*/
public void clearLightSources() {
this.lightSourcesLock.writeLock().lock();
var dynamicLightSources = this.dynamicLightSources.iterator();
IDynamicLightSource it;
while (dynamicLightSources.hasNext()) {
it = dynamicLightSources.next();
dynamicLightSources.remove();
if (SodiumWorldRenderer.getInstance() != null) {
if (it.angelica$getLuminance() > 0)
it.angelica$resetDynamicLight();
it.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
}
}
this.lightSourcesLock.writeLock().unlock();
}
/**
* Returns whether the light source is tracked or not.
*
* @param lightSource the light source to check
* @return {@code true} if the light source is tracked, else {@code false}
*/
public boolean containsLightSource(@NotNull IDynamicLightSource lightSource) {
boolean result;
this.lightSourcesLock.readLock().lock();
result = this.dynamicLightSources.contains(lightSource);
this.lightSourcesLock.readLock().unlock();
return result;
}
/**
* Returns the number of dynamic light sources that currently emit lights.
*
* @return the number of dynamic light sources emitting light
*/
public int getLightSourcesCount() {
int result;
this.lightSourcesLock.readLock().lock();
result = this.dynamicLightSources.size();
this.lightSourcesLock.readLock().unlock();
return result;
}
public double getDynamicLightLevel(int x, int y, int z) {
double result = 0;
this.lightSourcesLock.readLock().lock();
for (var lightSource : this.dynamicLightSources) {
result = maxDynamicLightLevel(x, y, z, lightSource, result);
}
this.lightSourcesLock.readLock().unlock();
return MathHelper.clamp_double(result, 0, 15);
}
public double getDynamicLightLevel(@NotNull BlockPosImpl pos) {
return this.getDynamicLightLevel(pos.getX(), pos.getY(), pos.getZ());
}
public static double maxDynamicLightLevel(int x, int y, int z, @NotNull IDynamicLightSource lightSource, double currentLightLevel) {
int luminance = lightSource.angelica$getLuminance();
if (luminance > 0) {
// Can't use Entity#squaredDistanceTo because of eye Y coordinate.
double dx = x - lightSource.angelica$getDynamicLightX() + 0.5;
double dy = y - lightSource.angelica$getDynamicLightY() + 0.5;
double dz = z - lightSource.angelica$getDynamicLightZ() + 0.5;
double distanceSquared = dx * dx + dy * dy + dz * dz;
// 7.75 because else we would have to update more chunks and that's not a good idea.
// 15 (max range for blocks) would be too much and a bit cheaty.
if (distanceSquared <= MAX_RADIUS_SQUARED) {
double multiplier = 1.0 - Math.sqrt(distanceSquared) / MAX_RADIUS;
double lightLevel = multiplier * (double) luminance;
if (lightLevel > currentLightLevel) {
return lightLevel;
}
}
}
return currentLightLevel;
}
/**
* Returns the dynamic light level generated by the light source at the specified position.
*
* @param pos the position
* @param lightSource the light source
* @param currentLightLevel the current surrounding dynamic light level
* @return the dynamic light level at the specified position
*/
public static double maxDynamicLightLevel(@NotNull BlockPosImpl pos, @NotNull IDynamicLightSource lightSource, double currentLightLevel) {
return maxDynamicLightLevel(pos.getX(), pos.getY(), pos.getZ(), lightSource, currentLightLevel);
}
public int getLightmapWithDynamicLight(int x, int y, int z, int lightmap) {
return this.getLightmapWithDynamicLight(this.getDynamicLightLevel(x, y, z), lightmap);
}
/**
* Returns the lightmap with combined light levels.
*
* @param dynamicLightLevel the dynamic light level
* @param lightmap the vanilla lightmap coordinates
* @return the modified lightmap coordinates
*/
public int getLightmapWithDynamicLight(double dynamicLightLevel, int lightmap) {
if (dynamicLightLevel > 0) {
// lightmap is (skyLevel << 20 | blockLevel << 4)
// Get vanilla block light level.
int blockLevel = (lightmap & 0xFFFF) >> 4;
if (dynamicLightLevel > blockLevel) {
// Equivalent to a << 4 bitshift with a little quirk: this one ensure more precision (more decimals are saved).
int luminance = (int) (dynamicLightLevel * 16.0);
lightmap &= 0xfff00000;
lightmap |= luminance & 0x000fffff;
}
}
return lightmap;
}
/**
* Schedules a chunk rebuild at the specified chunk position.
*
* @param renderer the renderer
* @param chunkPos the chunk position
*/
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, @NotNull BlockPosImpl chunkPos) {
scheduleChunkRebuild(renderer, chunkPos.getX(), chunkPos.getY(), chunkPos.getZ());
}
/**
* Schedules a chunk rebuild at the specified chunk position.
*
* @param renderer the renderer
* @param chunkPos the packed chunk position
*/
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, long chunkPos) {
scheduleChunkRebuild(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos));
}
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, int x, int y, int z) {
renderer.scheduleRebuildForChunk(x, y, z, false);
}
/**
* Updates the tracked chunk sets.
*
* @param chunkPos the packed chunk position
* @param old the set of old chunk coordinates to remove this chunk from it
* @param newPos the set of new chunk coordinates to add this chunk to it
*/
public static void updateTrackedChunks(@NotNull BlockPosImpl chunkPos, @Nullable LongOpenHashSet old, @Nullable LongOpenHashSet newPos) {
if (old != null || newPos != null) {
final long pos = chunkPos.asLong();
if (old != null)
old.remove(pos);
if (newPos != null)
newPos.add(pos);
}
}
/**
* Updates the dynamic lights tracking.
*
* @param lightSource the light source
*/
public static void updateTracking(@NotNull IDynamicLightSource lightSource) {
boolean enabled = lightSource.angelica$isDynamicLightEnabled();
int luminance = lightSource.angelica$getLuminance();
if (!enabled && luminance > 0) {
lightSource.angelica$setDynamicLightEnabled(true);
} else if (enabled && luminance < 1) {
lightSource.angelica$setDynamicLightEnabled(false);
}
}
/**
* Returns the luminance from an item stack.
*
* @param stack the item stack
* @param submergedInWater {@code true} if the stack is submerged in water, else {@code false}
* @return the luminance of the item
*/
public static int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater) {
// TODO only have certain items not glow in water?
if (submergedInWater) return 0;
Item item = stack.getItem();
if (item instanceof ItemBlock itemBlock) {
Block block = itemBlock.field_150939_a;
if (block != null) {
return block.getLightValue();
}
}
if (item == Items.lava_bucket) return Blocks.lava.getLightValue();
return 0;
}
public static int getLuminanceFromEntity(@NotNull Entity entity) {
if (entity.fire > 0) return 15;
if (entity instanceof EntityItem item) {
return getLuminanceFromItemStack(item.getEntityItem(), item.isInsideOfMaterial(Material.water));
}
if (entity instanceof EntityLivingBase living) {
int luminance = 0;
boolean inWater = living.isInsideOfMaterial(Material.water);
// check equipment + hand for light (should work for all entities)
ItemStack itemStack;
for (int i = 0; i < 5; i++) {
if ((itemStack = living.getEquipmentInSlot(i)) != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack, inWater));
}
}
if (ModStatus.isBattlegearLoaded &&
living instanceof EntityPlayer player &&
player instanceof IBattlePlayer battlePlayer &&
battlePlayer.battlegear2$isBattlemode()
) {
ItemStack offhand = ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
if (offhand != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
}
}
else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
ItemStack offhand = BackhandUtils.getOffhandItem(player);
if (offhand != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
}
}
return luminance;
}
// TODO: Creepers? TNT? Dusts?
return 0;
}
}
@@ -0,0 +1,35 @@
package com.gtnewhorizons.angelica.dynamiclights;
import java.util.Objects;
public enum DynamicLightsMode
{
OFF("Off", 0),
FASTEST("Fastest", 500),
FAST("Fast", 250),
FANCY("Fancy", 0);
private final String name;
private final int delay;
public boolean hasDelay() {
return delay > 0;
}
public int getDelay(){
return delay;
}
public String getName() {
return name;
}
DynamicLightsMode(String name, int delay) {
this.name = name;
this.delay = delay;
}
public boolean isEnabled() {
return !Objects.equals(this, DynamicLightsMode.OFF);
}
}
@@ -0,0 +1,86 @@
package com.gtnewhorizons.angelica.dynamiclights;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
public interface IDynamicLightSource {
/**
* Returns the dynamic light source X coordinate.
*
* @return the X coordinate
*/
double angelica$getDynamicLightX();
/**
* Returns the dynamic light source Y coordinate.
*
* @return the Y coordinate
*/
double angelica$getDynamicLightY();
/**
* Returns the dynamic light source Z coordinate.
*
* @return the Z coordinate
*/
double angelica$getDynamicLightZ();
/**
* Returns the dynamic light source world.
*
* @return the world instance
*/
SodiumWorldRenderer angelica$getDynamicLightWorld();
/**
* Returns whether the dynamic light is enabled or not.
*
* @return {@code true} if the dynamic light is enabled, else {@code false}
*/
default boolean angelica$isDynamicLightEnabled() {
return DynamicLights.isEnabled() && DynamicLights.get().containsLightSource(this);
}
/**
* Sets whether the dynamic light is enabled or not.
* <p>
* Note: please do not call this function in your mod or you will break things.
*
* @param enabled {@code true} if the dynamic light is enabled, else {@code false}
*/
@ApiStatus.Internal
default void angelica$setDynamicLightEnabled(boolean enabled) {
this.angelica$resetDynamicLight();
if (enabled)
DynamicLights.get().addLightSource(this);
else
DynamicLights.get().removeLightSource(this);
}
void angelica$resetDynamicLight();
/**
* Returns the luminance of the light source.
* The maximum is 15, below 1 values are ignored.
*
* @return the luminance of the light source
*/
int angelica$getLuminance();
/**
* Executed at each tick.
*/
void angelica$dynamicLightTick();
/**
* Returns whether this dynamic light source should update.
*
* @return {@code true} if this dynamic light source should update, else {@code false}
*/
boolean angelica$shouldUpdateDynamicLight();
boolean angelica$updateDynamicLight(@NotNull SodiumWorldRenderer renderer);
void angelica$scheduleTrackedChunksRebuild(@NotNull SodiumWorldRenderer renderer);
}
@@ -82,7 +82,14 @@ public class Feature {
, GLStateManager.depthTest // GL_DEPTH_TEST flag
// GL_DITHER flag
, GLStateManager.fogMode // GL_FOG flag
// GL_LIGHTi where 0 <= i < GL_MAX_LIGHTS
, GLStateManager.lightStates[0] // GL_LIGHT0
, GLStateManager.lightStates[1] // GL_LIGHT1
, GLStateManager.lightStates[2] // GL_LIGHT2
, GLStateManager.lightStates[3] // GL_LIGHT3
, GLStateManager.lightStates[4] // GL_LIGHT4
, GLStateManager.lightStates[5] // GL_LIGHT5
, GLStateManager.lightStates[6] // GL_LIGHT6
, GLStateManager.lightStates[7] // GL_LIGHT7
, GLStateManager.lightingState // GL_LIGHTING flag
// GL_LINE_SMOOTH flag
// GL_LINE_STIPPLE flag
@@ -149,9 +156,25 @@ public class Feature {
// GL_LIGHT_MODEL_TWO_SIDE setting
GLStateManager.lightingState // GL_LIGHTING enable bit
// Enable bit for each light
, GLStateManager.lightStates[0] // GL_LIGHT0
, GLStateManager.lightStates[1] // GL_LIGHT1
, GLStateManager.lightStates[2] // GL_LIGHT2
, GLStateManager.lightStates[3] // GL_LIGHT3
, GLStateManager.lightStates[4] // GL_LIGHT4
, GLStateManager.lightStates[5] // GL_LIGHT5
, GLStateManager.lightStates[6] // GL_LIGHT6
, GLStateManager.lightStates[7] // GL_LIGHT7
// Ambient, diffuse, and specular intensity for each light
// Direction, position, exponent, and cutoff angle for each light
// Constant, linear, and quadratic attenuation factors for each light
, GLStateManager.lightDataStates[0]
, GLStateManager.lightDataStates[1]
, GLStateManager.lightDataStates[2]
, GLStateManager.lightDataStates[3]
, GLStateManager.lightDataStates[4]
, GLStateManager.lightDataStates[5]
, GLStateManager.lightDataStates[6]
, GLStateManager.lightDataStates[7]
// Ambient, diffuse, specular, and emissive color for each material
// Ambient, diffuse, and specular color indices for each material
// Specular exponent for each material
@@ -11,6 +11,7 @@ import com.gtnewhorizons.angelica.glsm.stacks.DepthStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.FogStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.IStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.IntegerStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.LightStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.MatrixModeStack;
import com.gtnewhorizons.angelica.glsm.stacks.ViewPortStateStack;
import com.gtnewhorizons.angelica.glsm.states.Color4;
@@ -59,6 +60,7 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GLContext;
import java.lang.Math;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
@@ -105,7 +107,6 @@ public class GLStateManager {
@Getter protected static final DepthStateStack depthState = new DepthStateStack();
@Getter protected static final BooleanStateStack depthTest = new BooleanStateStack(GL11.GL_DEPTH_TEST);
// @Getter private static final FogState fogState = new FogState();
@Getter protected static final FogStateStack fogState = new FogStateStack();
@Getter protected static final BooleanStateStack fogMode = new BooleanStateStack(GL11.GL_FOG);
@Getter protected static final Color4Stack color = new Color4Stack();
@@ -122,9 +123,30 @@ public class GLStateManager {
@Getter protected static final Matrix4fStack modelViewMatrix = new Matrix4fStack(MAX_MODELVIEW_STACK_DEPTH);
@Getter protected static final Matrix4fStack projectionMatrix = new Matrix4fStack(MAX_PROJECTION_STACK_DEPTH);
@Getter protected static final BooleanStateStack[] lightStates = new BooleanStateStack[8];
@Getter protected static final LightStateStack[] lightDataStates = new LightStateStack[8];
static {
for (int i = 0; i < lightStates.length; i ++) {
lightStates[i] = new BooleanStateStack(GL11.GL_LIGHT0 + i);
lightDataStates[i] = new LightStateStack(GL11.GL_LIGHT0 + i);
}
}
@Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack();
public static void reset() {
runningSplash = true;
while(!attribs.isEmpty()) {
attribs.popInt();
}
for(IStateStack<?> stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) {
while(!stack.isEmpty()) {
stack.pop();
}
}
modelViewMatrix.clear();
projectionMatrix.clear();
}
// Iris Listeners
private static Runnable blendFuncListener = null;
@@ -224,6 +246,9 @@ public class GLStateManager {
}
public static boolean isMainThread() {
return Thread.currentThread() == MainThread;
}
public static void assertMainThread() {
if (Thread.currentThread() != CurrentThread && !runningSplash) {
@@ -244,6 +269,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> enableDepthTest();
case GL11.GL_FOG -> enableFog();
case GL11.GL_LIGHTING -> enableLighting();
case GL11.GL_LIGHT0 -> enableLight(0);
case GL11.GL_LIGHT1 -> enableLight(1);
case GL11.GL_LIGHT2 -> enableLight(2);
case GL11.GL_LIGHT3 -> enableLight(3);
case GL11.GL_LIGHT4 -> enableLight(4);
case GL11.GL_LIGHT5 -> enableLight(5);
case GL11.GL_LIGHT6 -> enableLight(6);
case GL11.GL_LIGHT7 -> enableLight(7);
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
case GL11.GL_TEXTURE_2D -> enableTexture();
case GL12.GL_RESCALE_NORMAL -> enableRescaleNormal();
@@ -259,6 +292,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> disableDepthTest();
case GL11.GL_FOG -> disableFog();
case GL11.GL_LIGHTING -> disableLighting();
case GL11.GL_LIGHT0 -> disableLight(0);
case GL11.GL_LIGHT1 -> disableLight(1);
case GL11.GL_LIGHT2 -> disableLight(2);
case GL11.GL_LIGHT3 -> disableLight(3);
case GL11.GL_LIGHT4 -> disableLight(4);
case GL11.GL_LIGHT5 -> disableLight(5);
case GL11.GL_LIGHT6 -> disableLight(6);
case GL11.GL_LIGHT7 -> disableLight(7);
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
case GL11.GL_TEXTURE_2D -> disableTexture();
case GL12.GL_RESCALE_NORMAL -> disableRescaleNormal();
@@ -277,6 +318,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
case GL11.GL_FOG -> fogMode.isEnabled();
case GL11.GL_LIGHTING -> lightingState.isEnabled();
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
case GL11.GL_LIGHT2 -> lightStates[2].isEnabled();
case GL11.GL_LIGHT3 -> lightStates[3].isEnabled();
case GL11.GL_LIGHT4 -> lightStates[4].isEnabled();
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
@@ -296,6 +345,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_WRITEMASK -> depthState.isEnabled();
case GL11.GL_FOG -> fogMode.isEnabled();
case GL11.GL_LIGHTING -> lightingState.isEnabled();
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
case GL11.GL_LIGHT2 -> lightStates[2].isEnabled();
case GL11.GL_LIGHT3 -> lightStates[3].isEnabled();
case GL11.GL_LIGHT4 -> lightStates[4].isEnabled();
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
@@ -366,6 +423,24 @@ public class GLStateManager {
}
public static void glGetLight(int light, int pname, FloatBuffer params) {
if (shouldBypassCache()) {
GL11.glGetLight(light, pname, params);
return;
}
LightStateStack state = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> state.ambient.get(0, params);
case GL11.GL_DIFFUSE -> state.diffuse.get(0, params);
case GL11.GL_SPECULAR -> state.specular.get(0, params);
case GL11.GL_POSITION -> state.position.get(0, params);
case GL11.GL_SPOT_DIRECTION -> state.spotDirection.get(0, params);
case GL11.GL_SPOT_EXPONENT -> params.put(state.spotExponent);
case GL11.GL_SPOT_CUTOFF -> params.put(state.spotCutoff);
case GL11.GL_CONSTANT_ATTENUATION -> params.put(state.constantAttenuation);
case GL11.GL_LINEAR_ATTENUATION -> params.put(state.linearAttenuation);
case GL11.GL_QUADRATIC_ATTENUATION -> params.put(state.quadraticAttenuation);
}
GL11.glGetLight(light, pname, params);
}
@@ -580,6 +655,8 @@ public class GLStateManager {
return ((b - Byte.MIN_VALUE) & 0xFF) / 255.0F;
}
public static float i2f(int i) { return ((i - Integer.MIN_VALUE) & 0xFFFFFF) / 4294967295.0F; }
private static boolean changeColor(float red, float green, float blue, float alpha) {
// Helper function for glColor*
if (shouldBypassCache() || red != color.getRed() || green != color.getGreen() || blue != color.getBlue() || alpha != color.getAlpha()) {
@@ -885,10 +962,18 @@ public class GLStateManager {
lightingState.enable();
}
public static void enableLight(int light) {
lightStates[light].enable();
}
public static void disableLighting() {
lightingState.disable();
}
public static void disableLight(int light) {
lightStates[light].disable();
}
public static void enableRescaleNormal() {
rescaleNormalState.enable();
}
@@ -1132,6 +1217,10 @@ public class GLStateManager {
}
}
public static Matrix4f getModelviewMatrix() {
return modelViewMatrix;
}
public static void glLoadIdentity() {
GL11.glLoadIdentity();
getMatrixStack().identity();
@@ -1247,6 +1336,9 @@ public class GLStateManager {
return true;
}
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
if (info == null) {
return true;
}
switch (pname) {
case GL11.GL_TEXTURE_MIN_FILTER -> {
if(info.getMinFilter() == param && !shouldBypassCache()) return false;
@@ -1318,6 +1410,9 @@ public class GLStateManager {
return true;
}
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
if (info == null) {
return true;
}
switch (pname) {
case EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT -> {
if(info.getMaxAnisotropy() == param && !shouldBypassCache()) return false;
@@ -1343,7 +1438,9 @@ public class GLStateManager {
public static int getTexParameterOrDefault(int texture, int pname, IntSupplier defaultSupplier) {
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
if (info == null) {
return defaultSupplier.getAsInt();
}
return switch (pname) {
case GL11.GL_TEXTURE_MIN_FILTER -> info.getMinFilter();
case GL11.GL_TEXTURE_MAG_FILTER -> info.getMagFilter();
@@ -1367,6 +1464,9 @@ public class GLStateManager {
return GL11.glGetTexParameterf(target, pname);
}
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(getBoundTexture());
if(info == null) {
return GL11.glGetTexParameterf(target, pname);
}
return switch (pname) {
case EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT -> info.getMaxAnisotropy();
@@ -1380,7 +1480,9 @@ public class GLStateManager {
return GL11.glGetTexLevelParameteri(target, level, pname);
}
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(getBoundTexture());
if (info == null) {
return GL11.glGetTexLevelParameteri(target, level, pname);
}
return switch (pname) {
case GL11.GL_TEXTURE_WIDTH -> info.getWidth();
case GL11.GL_TEXTURE_HEIGHT -> info.getHeight();
@@ -1390,10 +1492,61 @@ public class GLStateManager {
}
public static void glLight(int light, int pname, FloatBuffer params) {
GL11.glLight(light, pname, params);
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> lightState.setAmbient(params);
case GL11.GL_DIFFUSE -> lightState.setDiffuse(params);
case GL11.GL_SPECULAR -> lightState.setSpecular(params);
case GL11.GL_POSITION -> lightState.setPosition(params);
case GL11.GL_SPOT_DIRECTION -> lightState.setSpotDirection(params);
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(params);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(params);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(params);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(params);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(params);
default -> GL11.glLight(light, pname, params);
}
}
public static void glLight(int light, int pname, IntBuffer params) {
GL11.glLight(light, pname, params);
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> lightState.setAmbient(params);
case GL11.GL_DIFFUSE -> lightState.setDiffuse(params);
case GL11.GL_SPECULAR -> lightState.setSpecular(params);
case GL11.GL_POSITION -> lightState.setPosition(params);
case GL11.GL_SPOT_DIRECTION -> lightState.setSpotDirection(params);
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(params);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(params);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(params);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(params);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(params);
default -> GL11.glLight(light, pname, params);
}
}
public static void glLightf(int light, int pname, float param) {
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(param);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(param);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(param);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(param);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(param);
default -> GL11.glLightf(light, pname, param);
}
}
public static void glLighti(int light, int pname, int param) {
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(param);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(param);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(param);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(param);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(param);
default -> GL11.glLighti(light, pname, param);
}
}
public static void glLightModel(int pname, FloatBuffer params) {
@@ -34,4 +34,7 @@ public class AlphaStateStack extends AlphaState implements IStateStack<AlphaStat
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -34,4 +34,7 @@ public class BlendStateStack extends BlendState implements IStateStack<BlendStat
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -39,4 +39,7 @@ public class BooleanStateStack extends BooleanState implements IStateStack<Boole
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -39,4 +39,7 @@ public class Color4Stack extends Color4 implements IStateStack<Color4Stack> {
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -34,4 +34,7 @@ public class ColorMaskStack extends ColorMask implements IStateStack<ColorMaskSt
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -34,4 +34,7 @@ public class DepthStateStack extends DepthState implements IStateStack<DepthStat
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -34,4 +34,7 @@ public class FogStateStack extends FogState implements IStateStack<FogStateStack
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -6,4 +6,6 @@ public interface IStateStack<T>{
T pop();
boolean isEmpty();
}
@@ -39,4 +39,7 @@ public class IntegerStateStack extends IntegerState implements IStateStack<Integ
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -0,0 +1,39 @@
package com.gtnewhorizons.angelica.glsm.stacks;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.states.LightState;
public class LightStateStack extends LightState implements IStateStack<LightStateStack> {
protected final LightState[] stack;
protected int pointer;
public LightStateStack(int light) {
super(light);
stack = new LightState[GLStateManager.MAX_ATTRIB_STACK_DEPTH];
for (int i = 0; i < GLStateManager.MAX_ATTRIB_STACK_DEPTH; i++) {
stack[i] = new LightState(light);
}
}
public LightStateStack push() {
if (pointer == stack.length) {
throw new IllegalStateException("Stack overflow size " + (pointer + 1) + " reached");
}
stack[pointer++].set(this);
return this;
}
public LightStateStack pop() {
if (pointer == 0) {
throw new IllegalStateException("Stack underflow");
}
set(stack[--pointer]);
return this;
}
public boolean isEmpty() { return pointer == 0; }
}
@@ -34,4 +34,7 @@ public class MatrixModeStack extends MatrixMode implements IStateStack<MatrixMod
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -37,4 +37,8 @@ public class TextureBindingStack extends TextureBinding implements IStateStack<T
public TextureBinding peek() {
return stack[pointer];
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -32,4 +32,8 @@ public class Vector3dStack extends Vector3d implements IStateStack<Vector3dStack
set(stack[--pointer]);
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -34,4 +34,7 @@ public class ViewPortStateStack extends ViewportState implements IStateStack<Vie
return this;
}
public boolean isEmpty() {
return pointer == 0;
}
}
@@ -0,0 +1,291 @@
package com.gtnewhorizons.angelica.glsm.states;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.joml.Matrix3f;
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.joml.Vector4f;
import org.joml.Vector4i;
import org.lwjgl.opengl.GL11;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import static com.gtnewhorizons.angelica.glsm.GLStateManager.i2f;
public class LightState implements ISettableState<LightState> {
private static final Vector4i vector4i = new Vector4i();
private static final Vector4f vector4f = new Vector4f();
private static final Vector3i vector3i = new Vector3i();
private static final Vector3f vector3f = new Vector3f();
private static final Matrix3f matrix3f = new Matrix3f();
public int light;
public final Vector4f ambient;
public final Vector4f diffuse;
public final Vector4f specular;
public final Vector4f position;
public final Vector3f spotDirection;
public float spotExponent;
public float spotCutoff;
public float constantAttenuation;
public float linearAttenuation;
public float quadraticAttenuation;
public LightState(int light) {
this(
light,
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 1F, 0F),
new Vector3f(0F, 0F, -1F),
0F,
180F,
1.0F,
0.0F,
0.0F
);
if (light == GL11.GL_LIGHT0) {
this.diffuse.set(1F, 1F, 1F, 1F);
this.specular.set(1F, 1F, 1F, 1F);
}
}
public LightState(int light, Vector4f ambient, Vector4f diffuse, Vector4f specular, Vector4f position, Vector3f spotDirection, float spotExponent, float spotCutoff, float constantAttenuation, float linearAttenuation, float quadraticAttenuation) {
this.light = light;
this.ambient = ambient;
this.diffuse = diffuse;
this.specular = specular;
this.spotExponent = spotExponent;
this.spotCutoff = spotCutoff;
this.constantAttenuation = constantAttenuation;
this.linearAttenuation = linearAttenuation;
this.quadraticAttenuation = quadraticAttenuation;
this.position = position;
this.position.mul(GLStateManager.getModelviewMatrix());
this.spotDirection = spotDirection;
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.mul(matrix3f);
}
public void setAmbient(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.ambient.equals(vector4f)) {
this.ambient.set(vector4f);
GL11.glLight(this.light, GL11.GL_AMBIENT, newBuffer);
}
}
public void setAmbient(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.ambient.equals(vector4f)) {
this.ambient.set(vector4f);
GL11.glLight(this.light, GL11.GL_AMBIENT, newBuffer);
}
}
public void setDiffuse(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.diffuse.equals(vector4f)) {
this.diffuse.set(vector4f);
GL11.glLight(this.light, GL11.GL_DIFFUSE, newBuffer);
}
}
public void setDiffuse(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.diffuse.equals(vector4f)) {
this.diffuse.set(vector4f);
GL11.glLight(this.light, GL11.GL_DIFFUSE, newBuffer);
}
}
public void setSpecular(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.specular.equals(vector4f)) {
this.specular.set(vector4f);
GL11.glLight(this.light, GL11.GL_SPECULAR, newBuffer);
}
}
public void setSpecular(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.specular.equals(vector4f)) {
this.specular.set(vector4f);
GL11.glLight(this.light, GL11.GL_SPECULAR, newBuffer);
}
}
public void setPosition(FloatBuffer newBuffer) {
// We are bypassing cache everytime for position, because the necessary components to enable tracking the cache
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
this.position.set(newBuffer);
this.position.mul(GLStateManager.getModelviewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}
public void setPosition(IntBuffer newBuffer) {
vector4i.set(newBuffer);
this.position.set((float) vector4i.x, (float) vector4i.y, (float) vector4i.z, (float) vector4i.w);
this.position.mul(GLStateManager.getModelviewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}
public void setSpotDirection(FloatBuffer newBuffer) {
// We are bypassing cache everytime for spot direction, because the necessary components to enable tracking the cache
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.set(newBuffer);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
}
public void setSpotDirection(IntBuffer newBuffer) {
vector3i.set(newBuffer);
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.set((float) vector3i.x, (float) vector3i.y, (float) vector3i.z);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
}
public void setSpotExponent(FloatBuffer newBuffer) {
setSpotExponent(newBuffer.get());
}
public void setSpotExponent(IntBuffer newBuffer) {
setSpotExponent((float) newBuffer.get());
}
public void setSpotExponent(int i) {
setSpotExponent((float) i);
}
public void setSpotExponent(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.spotExponent) != 0) {
this.spotExponent = f;
GL11.glLightf(this.light, GL11.GL_SPOT_EXPONENT, f);
}
}
public void setSpotCutoff(FloatBuffer newBuffer) {
setSpotCutoff(newBuffer.get());
}
public void setSpotCutoff(IntBuffer newBuffer) {
setSpotCutoff((float) newBuffer.get());
}
public void setSpotCutoff(int i) {
setSpotCutoff((float) i);
}
public void setSpotCutoff(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.spotCutoff) != 0) {
this.spotCutoff = f;
GL11.glLightf(this.light, GL11.GL_SPOT_CUTOFF, f);
}
}
public void setConstantAttenuation(FloatBuffer newBuffer) {
setConstantAttenuation(newBuffer.get());
}
public void setConstantAttenuation(IntBuffer newBuffer) {
setConstantAttenuation((float) newBuffer.get());
}
public void setConstantAttenuation(int i) {
setConstantAttenuation((float) i);
}
public void setConstantAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.constantAttenuation) != 0) {
this.constantAttenuation = f;
GL11.glLightf(this.light, GL11.GL_CONSTANT_ATTENUATION, f);
}
}
public void setLinearAttenuation(FloatBuffer newBuffer) {
setLinearAttenuation(newBuffer.get());
}
public void setLinearAttenuation(IntBuffer newBuffer) {
setLinearAttenuation((float) newBuffer.get());
}
public void setLinearAttenuation(int i) {
setLinearAttenuation((float) i);
}
public void setLinearAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.linearAttenuation) != 0) {
this.linearAttenuation = f;
GL11.glLightf(this.light, GL11.GL_LINEAR_ATTENUATION, f);
}
}
public void setQuadraticAttenuation(FloatBuffer newBuffer) {
setQuadraticAttenuation(newBuffer.get());
}
public void setQuadraticAttenuation(IntBuffer newBuffer) {
setQuadraticAttenuation((float) newBuffer.get());
}
public void setQuadraticAttenuation(int i) {
setQuadraticAttenuation((float) i);
}
public void setQuadraticAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.quadraticAttenuation) != 0) {
this.quadraticAttenuation = f;
GL11.glLightf(this.light, GL11.GL_QUADRATIC_ATTENUATION, f);
}
}
@Override
public LightState set(LightState state) {
this.ambient.set(state.ambient);
this.diffuse.set(state.diffuse);
this.specular.set(state.specular);
this.position.set(state.position);
this.spotDirection.set(state.spotDirection);
this.spotExponent = state.spotExponent;
this.spotCutoff = state.spotCutoff;
this.constantAttenuation = state.constantAttenuation;
this.linearAttenuation = state.linearAttenuation;
this.quadraticAttenuation = state.quadraticAttenuation;
return this;
}
@Override
public boolean sameAs(Object state) {
if (this == state) return true;
if (!(state instanceof LightState lightState)) return false;
return this.ambient.equals(lightState.ambient)
&& this.diffuse.equals(lightState.diffuse)
&& this.specular.equals(lightState.specular)
&& this.position.equals(lightState.position)
&& this.spotDirection.equals(lightState.spotDirection)
&& Float.compare(this.spotCutoff, lightState.spotCutoff) == 0
&& Float.compare(this.spotExponent, lightState.spotExponent) == 0
&& Float.compare(this.linearAttenuation, lightState.linearAttenuation) == 0
&& Float.compare(this.constantAttenuation, lightState.constantAttenuation) == 0
&& Float.compare(this.quadraticAttenuation, lightState.quadraticAttenuation) == 0;
}
@Override
public LightState copy() { return new LightState(this.light).set(this); }
}
@@ -21,20 +21,23 @@ public class TextureInfoCache {
}
public TextureInfo getInfo(int id) {
if(id < 0 || !GLStateManager.isMainThread()) return null;
return cache.computeIfAbsent(id, TextureInfo::new);
}
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable IntBuffer pixels) {
if (level == 0) {
if (target == GL11.GL_TEXTURE_2D && level == 0) {
final TextureInfo info = getInfo(GLStateManager.getBoundTexture());
if(info == null) return;
info.internalFormat = internalformat;
info.width = width;
info.height = height;
}
}
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, long pixels_buffer_offset) {
if (level == 0) {
if (target == GL11.GL_TEXTURE_2D && level == 0) {
final TextureInfo info = getInfo(GLStateManager.getBoundTexture());
if(info == null) return;
info.internalFormat = internalformat;
info.width = width;
info.height = height;
@@ -42,7 +45,7 @@ public class TextureInfoCache {
}
public void onDeleteTexture(int id) {
cache.remove(id);
if(id >= 0 && GLStateManager.isMainThread()) cache.remove(id);
}
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.early.angelica.hudcaching.RenderGameOverlayEventAccessor;
import cpw.mods.fml.common.eventhandler.EventPriority;
import net.dries007.holoInventory.client.Renderer;
@@ -43,6 +44,7 @@ public class HUDCaching {
private static final Minecraft mc = Minecraft.getMinecraft();
public static Framebuffer framebuffer;
private static boolean dirty = true;
private static long nextHudRefresh;
public static boolean renderingCacheOverride;
@@ -106,13 +108,6 @@ public class HUDCaching {
/* TODO END REMOVE DEBUG STUFF */
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dirty = true;
}
}
// highest so it runs before the GLSM load event
@SubscribeEvent(priority = EventPriority.HIGH)
public void onJoinWorld(WorldEvent.Load event) {
@@ -136,8 +131,13 @@ public class HUDCaching {
return;
}
if (System.currentTimeMillis() > nextHudRefresh) {
dirty = true;
}
if (dirty) {
dirty = false;
nextHudRefresh = System.currentTimeMillis() + (1000 / AngelicaConfig.hudCachingFPS);
resetFramebuffer(mc.displayWidth, mc.displayHeight);
framebuffer.bindFramebuffer(false);
renderingCacheOverride = true;
@@ -1,7 +1,6 @@
package com.gtnewhorizons.angelica.mixins;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
@@ -29,6 +28,7 @@ public enum Mixins {
,"angelica.MixinEntityRenderer"
,"angelica.MixinMinecraft"
,"angelica.optimizations.MixinRendererLivingEntity"
,"angelica.MixinFMLClientHandler"
)
),
ANGELICA_VBO(
@@ -54,6 +54,20 @@ public enum Mixins {
,"angelica.debug.MixinTextureManager"
)
),
ANGELICA_DYNAMIC_LIGHTS(new Builder("Angelica Dynamic Lights").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableDynamicLights).addMixinClasses(
"angelica.dynamiclights.MixinEntityRenderer"
,"angelica.dynamiclights.MixinEntity"
,"angelica.dynamiclights.MixinWorld"
,"angelica.dynamiclights.MixinItemRenderer"
)
),
ANGELICA_FIX_FLUID_RENDERER_CHECKING_BLOCK_AGAIN(
new Builder("Fix RenderBlockFluid reading the block type from the world access multiple times")
.setPhase(Phase.EARLY).addMixinClasses("angelica.bugfixes.MixinRenderBlockFluid").setSide(Side.BOTH)
.setApplyIf(() -> AngelicaConfig.fixFluidRendererCheckingBlockAgain)
.addTargetedMod(TargetedMod.VANILLA)),
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
ARCHAIC_SPLASH(new Builder("ArchaicFix Splash").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
@@ -88,6 +102,7 @@ public enum Mixins {
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodium).addMixinClasses(
"sodium.MixinChunkProviderClient"
,"sodium.MixinBlock"
,"sodium.MixinBlockFluidBase"
,"sodium.AccessorBiomeColorEvent"
,"sodium.MixinBiomeGenBase"
,"sodium.MixinChunk"
@@ -192,6 +207,11 @@ public enum Mixins {
"client.extrautils.MixinRenderBlockConnectedTexturesEthereal",
"client.extrautils.MixinIconConnectedTexture")),
MFR_THREAD_SAFETY(new Builder("Enable thread safety fixes for MineFactory Reloaded").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.fixMineFactoryReloadedSodiumCompat)
.addMixinClasses("client.minefactoryreloaded.MixinRedNetCableRenderer")),
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
@@ -237,7 +257,9 @@ public enum Mixins {
"toggle.MixinEntityRenderer",
"toggle.MixinGuiIngame",
"toggle.MixinRender",
"toggle.MixinRenderItem"
"toggle.MixinRenderItem",
"interpolatedtexturemap.MixinTextureMap"
))
),
BETTER_FACE_CULLING(new Builder("Better face culling")
@@ -248,6 +270,7 @@ public enum Mixins {
"MixinBlock",
"MixinBlockCactus",
"MixinBlockCarpet",
"MixinBlockEnchantmentTable",
"MixinBlockFarmland",
"MixinBlockSlab",
"MixinBlockSnow",
@@ -272,6 +295,15 @@ public enum Mixins {
"MixinRenderItem"
))
),
NOTFINE_NATURA(new Builder("NotFine Natura compat")
.setSide(Side.CLIENT).setPhase(Phase.LATE)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
.addTargetedMod(TargetedMod.NATURA)
.addMixinClasses(addPrefix("notfine.leaves.natura.",
"MixinBerryBush",
"MixinNetherBerryBush"
))
),
NOTFINE_THAUMCRAFT(new Builder("NotFine Thaumcraft compat")
.setSide(Side.CLIENT).setPhase(Phase.LATE)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
@@ -288,6 +320,12 @@ public enum Mixins {
"MixinBlockTable"
))
),
NOTFINE_TINKERS_CONSTRUCT(new Builder("NotFine Tinker's Construct compat")
.setSide(Side.CLIENT).setPhase(Phase.LATE)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
.addTargetedMod(TargetedMod.TINKERS_CONSTRUCT)
.addMixinClasses("notfine.leaves.tconstruct.MixinOreberryBush")
),
NOTFINE_WITCHERY(new Builder("NotFine Witchery compat")
.setSide(Side.CLIENT).setPhase(Phase.LATE)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
@@ -319,12 +357,17 @@ public enum Mixins {
"base.MixinSimpleReloadableResourceManager",
"base.MixinMinecraft"
// TODO merge renderpass changes into Sodium renderer
// "renderpass.MixinEntityRenderer",
// "renderpass.MixinRenderBlocks",
// "renderpass.MixinRenderGlobal",
// "renderpass.MixinWorldRenderer"
))
),
MCPATCHER_FORGE_RENDERPASS(new Builder("MCPatcher Forge Renderpass")
.setPhase(Phase.EARLY)
.setApplyIf(() -> NotFineConfig.renderPass)
.addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses(addPrefix("mcpatcherforge.",
"renderpass.MixinEntityRenderer",
"renderpass.MixinRenderBlocks",
"renderpass.MixinRenderGlobal",
"renderpass.MixinWorldRenderer"
))
),
MCPATCHER_FORGE_CUSTOM_COLORS(new Builder("MCP:F Custom Colors")
@@ -385,7 +428,7 @@ public enum Mixins {
),
MCPATCHER_FORGE_CUSTOM_ITEM_TEXTURES(new Builder("MCP:F Custom Item Textures")
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures && MCPatcherForgeConfig.instance().customItemTexturesEnabled)
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().customItemTexturesEnabled)
.addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses(addPrefix("mcpatcherforge.cit.",
"client.renderer.entity.MixinRenderBiped",
@@ -410,7 +453,7 @@ public enum Mixins {
),
MCPATCHER_FORGE_EXTENDED_HD(new Builder("MCP:F Extended hd")
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled)
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled)
.addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses(addPrefix("mcpatcherforge.hd.",
"MixinTextureClock",
@@ -420,7 +463,7 @@ public enum Mixins {
),
MCPATCHER_FORGE_EXTENDED_HD_FONT(new Builder("MCP:F Extended HD Font")
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
.setApplyIf(() -> (AngelicaConfig.enableNotFineFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled && MCPatcherForgeConfig.instance().hdFont))
.setApplyIf(() -> (AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled && MCPatcherForgeConfig.instance().hdFont))
.addTargetedMod(TargetedMod.VANILLA)
.addExcludedMod(TargetedMod.COFHCORE)
.addMixinClasses("mcpatcherforge.hd.MixinFontRenderer")
@@ -522,10 +565,6 @@ public enum Mixins {
public static List<String> getEarlyMixins(Set<String> loadedCoreMods) {
NotFineConfig.loadSettings();
//These will probably break hard with Angelica.
//AdvancedOpenGL even breaks hard on its own.
NotFineConfig.allowAdvancedOpenGL = false;
NotFineConfig.allowToggleFBO = false;
//This may be possible to handle differently or fix.
if(loadedCoreMods.contains("cofh.asm.LoadingPlugin")) {
MCPatcherForgeConfig.instance().hdFont = false;
@@ -15,15 +15,18 @@ public enum TargetedMod {
, DYNAMIC_SURROUNDINGS_MIST("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround")
, DYNAMIC_SURROUNDINGS_ORIGINAL("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround")
, EXTRAUTILS("ExtraUtilities", null, "ExtraUtilities")
, MINEFACTORY_RELOADED("MineFactory Reloaded", null, "MineFactoryReloaded")
, GTNHLIB("GTNHLib", "com.gtnewhorizon.gtnhlib.core.GTNHLibCore", "gtnhlib")
, IC2("IC2", "ic2.core.coremod.IC2core", "IC2")
, JABBA("JABBA", null, "JABBA")
, JOURNEYMAP("JourneyMap", null, "journeymap")
, LWJGL3IFY("lwjgl3ify", "me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod", "lwjgl3ify")
, MRTJPCORE("MrTJPCore", null, "MrTJPCoreMod")
, NATURA("Natura", null, "Natura")
, PROJECTRED_ILLUMINATION("ProjectRed Illumination", null, "ProjRed|Illumination")
, SMART_RENDER("Smart Render", null, "SmartRender")
, THAUMCRAFT("Thaumcraft", null, "Thaumcraft")
, TINKERS_CONSTRUCT("Tinker's Construct", null, "TConstruct")
, TWILIGHT_FOREST("TwilightForest", null, "TwilightForest")
, WITCHERY("Witchery", null, "witchery")
;
@@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class)
@@ -23,4 +24,9 @@ public abstract class MixinEntityRenderer {
);
}
@ModifyArg(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", ordinal = 0), index = 0)
private float captureFov(float fov) {
RenderingState.INSTANCE.setFov(fov);
return fov;
}
}
@@ -0,0 +1,27 @@
package com.gtnewhorizons.angelica.mixins.early.angelica;
import cpw.mods.fml.client.FMLClientHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(value = FMLClientHandler.class, remap = false)
public class MixinFMLClientHandler {
/**
* @author mitchej123
* @reason Remove more traces of Optifine
*/
@Overwrite
private void detectOptifine() {
// Do nothing
}
/**
* @author mitchej123
* @reason Remove more traces of Optifine
*/
@Overwrite
public boolean hasOptifine() {
return false;
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.bugfixes;
import com.gtnewhorizons.angelica.mixins.hooks.FluidHooks;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.RenderBlockFluid;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import com.llamalad7.mixinextras.sugar.Local;
@Mixin(value = RenderBlockFluid.class, remap = false)
public class MixinRenderBlockFluid {
@Redirect(
method = "renderWorldBlock", at = @At(
value = "INVOKE",
target = "Lnet/minecraftforge/fluids/BlockFluidBase;getFlowDirection(Lnet/minecraft/world/IBlockAccess;III)D"))
double hodgepodge$directFlowDirectionCheck(IBlockAccess world, int x, int y, int z, @Local BlockFluidBase block) {
return FluidHooks.getFlowDirection(world, x, y, z, block);
}
}
@@ -0,0 +1,171 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.dynamiclights;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public abstract class MixinEntity implements IDynamicLightSource {
@Shadow
public World worldObj;
@Shadow
public double posX;
@Shadow
public double posY;
@Shadow
public double posZ;
@Shadow
public int chunkCoordX;
@Shadow
public int chunkCoordZ;
@Shadow
public abstract float getEyeHeight();
@Shadow
public boolean isDead;
@Unique
protected int angelica$luminance = 0;
@Unique
private int angelica$lastLuminance = 0;
@Unique
private static long angelica$lastUpdate = 0;
@Unique
private double angelica$prevX;
@Unique
private double angelica$prevY;
@Unique
private double angelica$prevZ;
@Unique
private LongOpenHashSet angelica$trackedLitChunkPos = new LongOpenHashSet();
@Override
public double angelica$getDynamicLightX() {
return posX;
}
@Override
public double angelica$getDynamicLightY() {
return posY + getEyeHeight();
}
@Override
public double angelica$getDynamicLightZ() {
return posZ;
}
@Override
public void angelica$resetDynamicLight() {
this.angelica$lastLuminance = 0;
}
@Override
public boolean angelica$shouldUpdateDynamicLight() {
if (DynamicLights.Mode.hasDelay()) {
long currentTime = System.currentTimeMillis();
if (currentTime < angelica$lastUpdate + DynamicLights.Mode.getDelay())
return false;
angelica$lastUpdate = currentTime;
}
return true;
}
@Inject(method = "onEntityUpdate", at = @At("TAIL"))
public void angelica$onUpdate(CallbackInfo ci) {
if (worldObj != null && worldObj.isRemote) {
if (isDead) {
angelica$setDynamicLightEnabled(false);
} else {
angelica$dynamicLightTick();
DynamicLights.updateTracking(this);
}
}
}
@Override
public void angelica$dynamicLightTick() {
this.angelica$luminance = DynamicLights.getLuminanceFromEntity((Entity) (Object) this);
}
@Override
public int angelica$getLuminance() {
return this.angelica$luminance;
}
@Override
public boolean angelica$updateDynamicLight(@NotNull SodiumWorldRenderer renderer) {
if (!this.angelica$shouldUpdateDynamicLight())
return false;
double deltaX = this.posX - this.angelica$prevX;
double deltaY = this.posY - this.angelica$prevY;
double deltaZ = this.posZ - this.angelica$prevZ;
int luminance = this.angelica$getLuminance();
if (Math.abs(deltaX) > 0.1D || Math.abs(deltaY) > 0.1D || Math.abs(deltaZ) > 0.1D || luminance != this.angelica$lastLuminance) {
this.angelica$prevX = this.posX;
this.angelica$prevY = this.posY;
this.angelica$prevZ = this.posZ;
this.angelica$lastLuminance = luminance;
var newPos = new LongOpenHashSet();
if (luminance > 0) {
var chunkPos = new BlockPosImpl(chunkCoordX, MathHelper.floor_double(posY + getEyeHeight()) >> 4, chunkCoordZ);
DynamicLights.scheduleChunkRebuild(renderer, chunkPos);
DynamicLights.updateTrackedChunks(chunkPos, this.angelica$trackedLitChunkPos, newPos);
var directionX = ((MathHelper.floor_double(posX) & 15) >= 8) ? ForgeDirection.EAST : ForgeDirection.WEST;
var directionY = ((MathHelper.floor_double(posY + getEyeHeight()) & 15) >= 8) ? ForgeDirection.UP : ForgeDirection.DOWN;
var directionZ = ((MathHelper.floor_double(posZ) & 15) >= 8) ? ForgeDirection.SOUTH : ForgeDirection.NORTH;
for (int i = 0; i < 7; i++) {
if (i % 4 == 0) {
chunkPos = chunkPos.offset(directionX); // X
} else if (i % 4 == 1) {
chunkPos = chunkPos.offset(directionZ); // XZ
} else if (i % 4 == 2) {
chunkPos = chunkPos.offset(directionX.getOpposite()); // Z
} else {
chunkPos = chunkPos.offset(directionZ.getOpposite()); // origin
chunkPos = chunkPos.offset(directionY); // Y
}
DynamicLights.scheduleChunkRebuild(renderer, chunkPos);
DynamicLights.updateTrackedChunks(chunkPos, this.angelica$trackedLitChunkPos, newPos);
}
}
// Schedules the rebuild of removed chunks.
this.angelica$scheduleTrackedChunksRebuild(renderer);
// Update tracked lit chunks.
this.angelica$trackedLitChunkPos = newPos;
return true;
}
return false;
}
@Override
public void angelica$scheduleTrackedChunksRebuild(@NotNull SodiumWorldRenderer renderer) {
for (long pos : this.angelica$trackedLitChunkPos) {
DynamicLights.scheduleChunkRebuild(renderer, pos);
}
}
}
@@ -0,0 +1,23 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.dynamiclights;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class)
public class MixinEntityRenderer {
@Shadow
private Minecraft mc;
@Inject(method = "renderWorld", at = @At("HEAD"))
private void updateDynamicLights(float p_78471_1_, long p_78471_2_, CallbackInfo ci){
mc.mcProfiler.endStartSection("angelica_dynamic_lighting");
DynamicLights.get().updateAll(SodiumWorldRenderer.getInstance());
}
}
@@ -0,0 +1,23 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.dynamiclights;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.ItemRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(ItemRenderer.class)
public class MixinItemRenderer {
@WrapOperation(method = "renderItemInFirstPerson", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;getLightBrightnessForSkyBlocks(IIII)I"))
private int angelica$dynamiclights_renderItemInFirstPerson(WorldClient theWorld, int posX, int posY, int posZ, int p_72802_4_, Operation<Integer> original){
int lightmap = original.call(theWorld, posX, posY, posZ, p_72802_4_);
if (DynamicLights.isEnabled()){
lightmap = (int)DynamicLights.get().getLightmapWithDynamicLight(posX, posY, posZ, lightmap);
}
return lightmap;
}
}
@@ -0,0 +1,39 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.dynamiclights;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(World.class)
public abstract class MixinWorld {
@Shadow
protected abstract void initialize(WorldSettings p_72963_1_);
@Shadow
public abstract Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_);
@Inject(method = "onEntityRemoved", at = @At("HEAD"))
private void angelica$removeEntity(Entity entity, CallbackInfo ci){
if (entity instanceof IDynamicLightSource lightSource){
lightSource.angelica$setDynamicLightEnabled(false);
}
}
@ModifyReturnValue(method = "getLightBrightnessForSkyBlocks", at = @At(value = "RETURN"))
private int angelica$dynamiclights_getLightBrightnessForSkyBlocks(int lightmap, int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_){
if (DynamicLights.isEnabled()){
return DynamicLights.get().getLightmapWithDynamicLight(p_72802_1_, p_72802_2_, p_72802_3_, lightmap);
}
return lightmap;
}
}
@@ -103,7 +103,7 @@ public abstract class MixinFontRenderer implements FontRendererAccessor {
@Shadow
protected abstract String bidiReorder(String p_147647_1_);
@Shadow
@Shadow(remap = false)
protected abstract void bindTexture(ResourceLocation location);
@Unique
@@ -0,0 +1,50 @@
package com.gtnewhorizons.angelica.mixins.early.notfine.faceculling;
import jss.notfine.util.IFaceObstructionCheckHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEnchantmentTable;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(value = BlockEnchantmentTable.class)
public abstract class MixinBlockEnchantmentTable extends Block implements IFaceObstructionCheckHelper {
/**
* @author jss2a98aj
* @reason More accurate face culling.
*/
public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) {
//If this is the top
if(side == 1) {
return true;
}
//Check if other block is solid
Block otherBlock = worldIn.getBlock(x, y, z);
if(otherBlock.isOpaqueCube()) {
return false;
}
//Check for IFaceObstructionCheckHelper
if(otherBlock instanceof IFaceObstructionCheckHelper target) {
return target.isFaceNonObstructing(worldIn, x, y, z, side, 0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
}
//Default
return true;
}
@Override
public boolean isFaceNonObstructing(IBlockAccess worldIn, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
if(getRenderBlockPass() == 1) {
return true;
}
if(side <= 1) {
return side == 0;
}
return otherMaxY > 0.75F;
}
private MixinBlockEnchantmentTable(Material material) {
super(material);
}
}
@@ -17,7 +17,7 @@ public abstract class MixinRenderBlocks {
/**
* @author jss2a98aj
* @reason Culling a few more faces
* @reason Do not render fence arms unless actually required.
*/
@Overwrite
public boolean renderBlockFence(BlockFence fence, int x, int y, int z) {
@@ -69,6 +69,30 @@ public abstract class MixinRenderBlocks {
return true;
}
/**
* @author jss2a98aj
* @reason Cull faces against solid blocks, fix door smooth lighting
*/
@Overwrite
public boolean renderBlockDoor(Block block, int x, int y, int z) {
final int meta = blockAccess.getBlockMetadata(x, y, z);
if((meta & 8) != 0) {
if (blockAccess.getBlock(x, y - 1, z) != block) {
return false;
}
} else if (blockAccess.getBlock(x, y + 1, z) != block) {
return false;
}
if ((meta & 8) != 0) {
uvRotateTop = meta % 6;
}
boolean flag = renderStandardBlock(block, x, y, z);
uvRotateTop = 0;
return flag;
}
/**
* @author jss2a98aj
* @reason Fix modded wall detection
@@ -87,6 +111,7 @@ public abstract class MixinRenderBlocks {
@Shadow public IBlockAccess blockAccess;
@Shadow public boolean field_152631_f;
@Shadow public int uvRotateTop;
@Shadow public abstract void setRenderBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ);
@Shadow public abstract boolean renderStandardBlock(Block blockType, int blockX, int blockY, int blockZ);
@@ -0,0 +1,51 @@
package com.gtnewhorizons.angelica.mixins.early.notfine.interpolatedtexturemap;
import com.google.gson.JsonObject;
import jss.notfine.render.InterpolatedIcon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.ITickableTextureObject;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.SimpleResource;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
@Mixin(TextureMap.class)
public abstract class MixinTextureMap extends AbstractTexture implements ITickableTextureObject, IIconRegister {
@Shadow
@Final
private Map mapRegisteredSprites;
@Shadow
protected abstract ResourceLocation completeResourceLocation(ResourceLocation p_147634_1_, int p_147634_2_);
@Inject(method = "registerIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;<init>(Ljava/lang/String;)V"), cancellable = true)
private void registerInterpolatedIcon(String textureName, CallbackInfoReturnable<IIcon> cir) {
try {
IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(completeResourceLocation(new ResourceLocation(textureName), 0));
if (resource instanceof SimpleResource) {
//This returns IMetadataSections, which seems to already remove unused mcmeta fields in 1.7.10
//I'm just running this to populate the mcmetaJson field more easily; this does it for us
if (resource.getMetadata("animation") != null) {
JsonObject mcmetaJson = ((SimpleResource) resource).mcmetaJson;
if (mcmetaJson.getAsJsonObject("animation").getAsJsonPrimitive("interpolate").getAsBoolean()) {
InterpolatedIcon interpolatedIcon = new InterpolatedIcon(textureName);
mapRegisteredSprites.put(textureName, interpolatedIcon);
cir.setReturnValue(interpolatedIcon);
}
}
}
} catch (Exception ignored) {/*Should quietly fail, no need to fail hard*/}
}
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.notfine.leaves;
import jss.notfine.util.IFaceObstructionCheckHelper;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.Block;
@@ -9,13 +10,18 @@ import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(value = BlockLeavesBase.class)
public abstract class MixinBlockLeavesBase extends Block implements ILeafBlock {
public abstract class MixinBlockLeavesBase extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side);
}
@Override()
public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
}
private MixinBlockLeavesBase(Material material) {
super(material);
}
@@ -14,6 +14,8 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.lwjgl.opengl.GL11;
@Mixin(EntityRenderer.class)
abstract public class MixinEntityRenderer {
@@ -30,6 +32,10 @@ abstract public class MixinEntityRenderer {
return SettingsManager.waterDetail;
}
/**
* @author Caedis
* @reason Void fog toggle
*/
@WrapOperation(
method = "setupFog",
at = @At(
@@ -37,10 +43,22 @@ abstract public class MixinEntityRenderer {
target = "Lnet/minecraft/world/WorldProvider;getWorldHasVoidParticles()Z"
)
)
private boolean angelica$wrapVoidFog(WorldProvider provider, Operation<Boolean> original){
private boolean notFine$toggleVoidFog(WorldProvider provider, Operation<Boolean> original){
return ((boolean)Settings.VOID_FOG.option.getStore()) ? original.call(provider) : false;
}
@Redirect(
method = "setupFog",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V",
ordinal = 14
)
)
private void notFine$nearFogDistance(int mode, float value) {
GL11.glFogf(mode, farPlaneDistance * (int)Settings.FOG_NEAR_DISTANCE.option.getStore() * 0.01F - 1F);
}
@Redirect(
method = "updateRenderer()V",
at = @At(
@@ -48,7 +66,7 @@ abstract public class MixinEntityRenderer {
target = "Lnet/minecraft/client/renderer/EntityRenderer;updateTorchFlicker()V"
)
)
private void toggleTorchFlicker(EntityRenderer instance) {
private void notFine$toggleTorchFlicker(EntityRenderer instance) {
if((boolean)Settings.MODE_LIGHT_FLICKER.option.getStore()) {
updateTorchFlicker();
} else {
@@ -59,6 +77,10 @@ abstract public class MixinEntityRenderer {
@Shadow
abstract void updateTorchFlicker();
@Shadow private boolean lightmapUpdateNeeded;
@Shadow
private boolean lightmapUpdateNeeded;
@Shadow
private float farPlaneDistance;
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.sodium;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraftforge.fluids.BlockFluidBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(value = BlockFluidBase.class, remap = false)
public class MixinBlockFluidBase {
@WrapOperation(method = "getFlowDirection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/material/Material;isLiquid()Z"), remap = true)
private static boolean isLiquid(Material instance, Operation<Boolean> original, @Local Block block) {
if (block instanceof BlockFluidBase) {
return original.call(instance);
} else {
return false;
}
}
}
@@ -5,6 +5,9 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.chunk.Chunk;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.endlessids.EndlessIDsCompat;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -29,14 +32,18 @@ public abstract class MixinChunk {
if(this.worldObj.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {
// We are in multiplayer, the server might not have sent all biomes to the client.
// Populate them now while we're on the main thread.
WorldChunkManager manager = this.worldObj.getWorldChunkManager();
for(int z = 0; z < 16; z++) {
for(int x = 0; x < 16; x++) {
int idx = (z << 4) + x;
int biome = this.blockBiomeArray[idx] & 255;
if(biome == 255) {
BiomeGenBase generated = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
this.blockBiomeArray[idx] = (byte)(generated.biomeID & 255);
if (ModStatus.isEIDBiomeLoaded) {
EndlessIDsCompat.sodium$populateBiomes((Chunk) (Object) this);
} else {
WorldChunkManager manager = this.worldObj.getWorldChunkManager();
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
int idx = (z << 4) + x;
int biome = this.blockBiomeArray[idx] & 255;
if (biome == 255) {
BiomeGenBase generated = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
this.blockBiomeArray[idx] = (byte) (generated.biomeID & 255);
}
}
}
}
@@ -254,6 +254,10 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
@Inject(method = "loadRenderers", at = @At("RETURN"))
private void onReload(CallbackInfo ci) {
reload();
}
public void reload() {
RenderDevice.enterManagedCode();
try {
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.sodium;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import me.jellysquid.mods.sodium.client.gui.options.named.LightingQuality;
import me.jellysquid.mods.sodium.client.model.light.EntityLighter;
import net.minecraft.client.Minecraft;
@@ -17,10 +18,20 @@ public class MixinRenderManager {
*/
@Redirect(method = "renderEntityStatic", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getBrightnessForRender(F)I"))
private int sodium$getBrightnessForRender(Entity self, float partialTicks) {
int lightmap;
if (Minecraft.getMinecraft().gameSettings.ambientOcclusion == LightingQuality.HIGH.getVanilla()) {
return EntityLighter.getBlendedLight(self, partialTicks);
lightmap = EntityLighter.getBlendedLight(self, partialTicks);
}else {
lightmap = self.getBrightnessForRender(partialTicks);
}
return self.getBrightnessForRender(partialTicks);
if (DynamicLights.isEnabled()){
int dynamicLightLevel = (int) DynamicLights.get().getDynamicLightLevel((int)self.posX, (int)self.posY, (int)self.posZ);
if (dynamicLightLevel > 0) {
lightmap = DynamicLights.get().getLightmapWithDynamicLight(dynamicLightLevel, lightmap);
}
}
return lightmap;
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.hooks;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidBase;
public class FluidHooks {
/**
* {@link BlockFluidBase#getFluid()} that uses the given Block instead of fetching it from the world again
*/
public static double getFlowDirection(IBlockAccess world, int x, int y, int z, BlockFluidBase block) {
if (!block.getMaterial().isLiquid()) {
return -1000.0;
}
Vec3 vec = block.getFlowVector(world, x, y, z);
return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D;
}
}
@@ -2,5 +2,6 @@ package com.gtnewhorizons.angelica.mixins.interfaces;
public interface IRenderGlobalExt {
void scheduleTerrainUpdate();
void reload();
}
@@ -14,20 +14,20 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
@Mixin(targets = "connor135246.campfirebackport.client.rendering.RenderBlockCampfire", remap = false)
@Mixin(value = connor135246.campfirebackport.client.rendering.RenderBlockCampfire.class, remap = false)
public class MixinRenderBlockCampfire {
@Inject(method = "renderFace", at = @At("HEAD"))
private static void angelica$beforeRenderFace(double x, double y, double z, Block block, RenderBlocks renderer, IIcon icon, int side, CallbackInfo ci) {
AnimationsRenderUtils.markBlockTextureForUpdate(icon, renderer.blockAccess);
((ITexturesCache)renderer).getRenderedTextures().add(icon);
}
@ModifyArgs(method = "renderFire", at = @At(value = "INVOKE", target = "Lconnor135246/campfirebackport/client/rendering/RenderBlockCampfire;drawCrossedSquaresTwoIcons(Lnet/minecraft/util/IIcon;Lnet/minecraft/util/IIcon;DDDF)V"))
private static void angelica$onDrawCrossedSquaresTwoIcons(Args args, double x, double y, double z, Block block, RenderBlocks renderer, boolean mix) {
IIcon icon1 = (IIcon)args.get(0);
AnimationsRenderUtils.markBlockTextureForUpdate(icon1, renderer.blockAccess);
((ITexturesCache)renderer).getRenderedTextures().add(icon1);
IIcon icon2 = (IIcon)args.get(1);
AnimationsRenderUtils.markBlockTextureForUpdate(icon2, renderer.blockAccess);
((ITexturesCache)renderer).getRenderedTextures().add(icon2);
@@ -0,0 +1,31 @@
package com.gtnewhorizons.angelica.mixins.late.client.minefactoryreloaded;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import powercrystals.minefactoryreloaded.render.block.RedNetCableRenderer;
import powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable;
@Mixin(value = RedNetCableRenderer.class)
public abstract class MixinRedNetCableRenderer extends TileEntitySpecialRenderer {
/**
* @author JL2210
* @reason Thread safety compat (check result of getTileEntity for null)
*/
@Inject(method = "renderWorldBlock", at = @At(value = "FIELD", target = "Lpowercrystals/minefactoryreloaded/setup/MFRConfig;TESRCables*:Z"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, remap = false)
public void angelica$checkNullBeforeAccess(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer, CallbackInfoReturnable<Boolean> cir, TileEntityRedNetCable _cable) {
if (_cable == null) {
cir.setReturnValue(false);
}
}
}
@@ -0,0 +1,78 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.natura;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.IFaceObstructionCheckHelper;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import mods.natura.blocks.crops.BerryBush;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = BerryBush.class)
public abstract class MixinBerryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
final int metadata = world.getBlockMetadata(x, y, z);
int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4);
boolean renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
if(metadata < 8) {
renderMode = false;
} else {
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
final Block otherBlock = world.getBlock(x, y, z);
renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z);
}
} else {
renderMode = SettingsManager.leavesOpaque;
}
maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta;
return (renderMode ? fastIcons : fancyIcons)[maskedMeta];
}
/**
* @author jss2a98aj
* @reason Support new leaf rendering modes on Natura leaves.
*/
@Overwrite
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
if (side != 0 && maxY < 1f) {
return true;
}
return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side);
}
@Override
public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
if(world.getBlockMetadata(x ,y, z) < 8) {
return true;
}
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
}
@Override
public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) {
return world.getBlockMetadata(x ,y, z) >= 8;
}
@Shadow(remap = false)
public IIcon[] fastIcons;
@Shadow(remap = false)
public IIcon[] fancyIcons;
private MixinBerryBush(Material materialIn) {
super(materialIn);
}
}
@@ -0,0 +1,78 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.natura;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.IFaceObstructionCheckHelper;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import mods.natura.blocks.crops.NetherBerryBush;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = NetherBerryBush.class)
public abstract class MixinNetherBerryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
final int metadata = world.getBlockMetadata(x, y, z);
int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4);
boolean renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
if(metadata < 8) {
renderMode = false;
} else {
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
final Block otherBlock = world.getBlock(x, y, z);
renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z);
}
} else {
renderMode = SettingsManager.leavesOpaque;
}
maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta;
return (renderMode ? fastIcons : fancyIcons)[maskedMeta];
}
/**
* @author jss2a98aj
* @reason Support new leaf rendering modes on Natura leaves.
*/
@Overwrite
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
if (side != 0 && maxY < 1f) {
return true;
}
return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side);
}
@Override
public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
if(world.getBlockMetadata(x ,y, z) < 8) {
return true;
}
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
}
@Override
public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) {
return world.getBlockMetadata(x ,y, z) >= 8;
}
@Shadow(remap = false)
public IIcon[] fastIcons;
@Shadow(remap = false)
public IIcon[] fancyIcons;
private MixinNetherBerryBush(Material materialIn) {
super(materialIn);
}
}
@@ -0,0 +1,78 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.tconstruct;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.IFaceObstructionCheckHelper;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import tconstruct.world.blocks.OreberryBush;
@Mixin(value = OreberryBush.class)
public abstract class MixinOreberryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
final int metadata = world.getBlockMetadata(x, y, z);
int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4);
boolean renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
if(metadata < 8) {
renderMode = false;
} else {
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
final Block otherBlock = world.getBlock(x, y, z);
renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z);
}
} else {
renderMode = SettingsManager.leavesOpaque;
}
maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta;
return (renderMode ? fastIcons : fancyIcons)[maskedMeta];
}
/**
* @author jss2a98aj
* @reason Support new leaf rendering modes on Tinker's Construct leaves.
*/
@Overwrite
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
if (side != 0 && maxY < 1f) {
return true;
}
return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side);
}
@Override
public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
if(world.getBlockMetadata(x ,y, z) < 8) {
return true;
}
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
}
@Override
public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) {
return world.getBlockMetadata(x ,y, z) >= 8;
}
@Shadow(remap = false)
public IIcon[] fastIcons;
@Shadow(remap = false)
public IIcon[] fancyIcons;
private MixinOreberryBush(Material material) {
super(material);
}
}
@@ -1,13 +1,10 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.thaumcraft;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.IFaceObstructionCheckHelper;
import jss.notfine.util.ILeafBlock;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@@ -16,21 +13,12 @@ import org.spongepowered.asm.mixin.Shadow;
import thaumcraft.common.blocks.BlockMagicalLeaves;
@Mixin(value = BlockMagicalLeaves.class)
public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBlock {
public abstract class MixinBlockMagicalLeaves extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return icon[renderMode + maskedMeta * 2];
}
@@ -44,6 +32,11 @@ public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBloc
return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side);
}
@Override()
public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
}
private MixinBlockMagicalLeaves(Material material) {
super(material);
}
@@ -1,12 +1,8 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.BlockLeaves;
import net.minecraft.init.Blocks;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@@ -18,16 +14,7 @@ public abstract class MixinBlockTFLeaves extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return Blocks.leaves.field_150129_M[renderMode][maskedMeta];
}
@@ -1,12 +1,8 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.BlockLeaves;
import net.minecraft.init.Blocks;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@@ -17,16 +13,7 @@ public abstract class MixinBlockTFLeaves3 extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
return Blocks.leaves.field_150129_M[renderMode][0];
}
@@ -1,11 +1,7 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.BlockLeaves;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@@ -17,21 +13,12 @@ public abstract class MixinBlockTFMagicLeaves extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
final boolean renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side);
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return switch (maskedMeta) {
case 1 -> renderMode == 1 ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
case 3 -> renderMode == 1 ? SPR_SORTLEAVES_OPAQUE : SPR_SORTLEAVES;
default -> renderMode == 1 ? SPR_TIMELEAVES_OPAQUE : SPR_TIMELEAVES;
case 1 -> renderMode ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
case 3 -> renderMode ? SPR_SORTLEAVES_OPAQUE : SPR_SORTLEAVES;
default -> renderMode ? SPR_TIMELEAVES_OPAQUE : SPR_TIMELEAVES;
};
}
@@ -1,13 +1,10 @@
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.witchery;
import com.emoniph.witchery.blocks.BlockWitchLeaves;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import jss.notfine.util.ILeafBlock;
import jss.notfine.util.LeafRenderUtil;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
@@ -29,16 +26,7 @@ public abstract class MixinBlockWitchLeaves extends BlockLeavesBase {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return iconsForModes[renderMode][maskedMeta];
}
@@ -3,7 +3,9 @@ package com.gtnewhorizons.angelica.proxy;
import com.google.common.base.Objects;
import com.gtnewhorizons.angelica.common.BlockTest;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.debug.OpenGLDebugging;
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
@@ -81,7 +83,7 @@ public class ClientProxy extends CommonProxy {
if(AngelicaConfig.enableSodium) {
// Register all blocks. Because blockids are unique to a world, this must be done each load
GameData.getBlockRegistry().forEach(o -> {
final Block b = (Block) o;
AngelicaBlockSafetyRegistry.canBlockRenderOffThread(b, true, true);
AngelicaBlockSafetyRegistry.canBlockRenderOffThread(b, false, true);
@@ -119,6 +121,10 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.registerKeyBinding(glsmKeyBinding);
Loader.loadModels();
if(ModStatus.isBetterCrashesLoaded) {
BetterCrashesCompat.init();
}
}
private boolean wasGLSMKeyPressed;
@@ -183,6 +189,16 @@ public class ClientProxy extends CommonProxy {
event.right.add(Block.blockRegistry.getNameForObject(block));
event.right.add("meta: " + meta);
}
if (DynamicLights.isEnabled()){
var builder = new StringBuilder("Dynamic Light Sources: ");
DynamicLights dl = DynamicLights.get();
builder.append(dl.getLightSourcesCount())
.append(" (U: ")
.append(dl.getLastUpdateCount())
.append(')');
event.right.add(builder.toString());
}
if(AngelicaConfig.modernizeF3Screen) {
boolean hasReplacedXYZ = false;
for(int i = 0; i < event.left.size() - 3; i++) {
@@ -30,7 +30,6 @@ import com.gtnewhorizons.angelica.glsm.TessellatorManager;
import com.gtnewhorizons.angelica.glsm.VBOManager;
import jss.notfine.core.Settings;
import jss.notfine.gui.options.named.GraphicsQualityOff;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -65,6 +64,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
private VertexBuffer vbo;
private int cloudMode = -1;
private int renderDistance = -1;
private int cloudElevation = -1;
private int scaleMult = -1;
private DynamicTexture COLOR_TEX = null;
@@ -83,9 +84,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
return instance;
}
private int getScale() {
return cloudMode == 2 ? 12 : 8;
return (cloudMode == 2 ? 12 : 8) * scaleMult;
}
private float ceilToScale(float value) {
@@ -140,11 +140,12 @@ public class CloudRenderer implements IResourceManagerReloadListener {
tessellator.pos(sectX0, 0, sectZ1).tex(u0, v1).color(bCol, bCol, bCol, ALPHA).endVertex();
if (fancy) {
final int height = HEIGHT * scaleMult;
// Top
tessellator.pos(sectX0, HEIGHT, sectZ0).tex(u0, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, sectZ1).tex(u0, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, sectZ1).tex(u1, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, sectZ0).tex(u1, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, height, sectZ0).tex(u0, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, height, sectZ1).tex(u0, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, height, sectZ1).tex(u1, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, height, sectZ0).tex(u1, v0).color(1, 1, 1, ALPHA).endVertex();
float slice;
float sliceCoord0;
@@ -158,8 +159,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice > -CULL_DIST) {
slice += INSET;
tessellator.pos(slice, 0, sectZ1).tex(sliceCoord0, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, 0, sectZ0).tex(sliceCoord0, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
slice -= INSET;
}
@@ -169,8 +170,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice <= CULL_DIST) {
slice -= INSET;
tessellator.pos(slice, 0, sectZ0).tex(sliceCoord0, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, 0, sectZ1).tex(sliceCoord0, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
slice += INSET;
}
@@ -184,8 +185,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice > -CULL_DIST) {
slice += INSET;
tessellator.pos(sectX0, 0, slice).tex(u0, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, height, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, height, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, 0, slice).tex(u1, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
slice -= INSET;
}
@@ -195,8 +196,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice <= CULL_DIST) {
slice -= INSET;
tessellator.pos(sectX1, 0, slice).tex(u1, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, height, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, height, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, 0, slice).tex(u0, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
slice += INSET;
}
@@ -239,21 +240,32 @@ public class CloudRenderer implements IResourceManagerReloadListener {
public void checkSettings() {
GraphicsQualityOff cloudGraphicsQuality = (GraphicsQualityOff)Settings.MODE_CLOUDS.option.getStore();
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
|| cloudGraphicsQuality == GraphicsQualityOff.DEFAULT && mc.gameSettings.fancyGraphics ? 2 : 1;
boolean newEnabled = mc.gameSettings.shouldRenderClouds()
final boolean newEnabled = mc.gameSettings.shouldRenderClouds()
&& mc.theWorld != null
&& mc.theWorld.provider.isSurfaceWorld();
final int targetDistance = Math.max(mc.gameSettings.renderDistanceChunks, (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
final int cloudScaleMult = (int)Settings.CLOUD_SCALE.option.getStore();
if (isBuilt()
&& (!newEnabled
|| cloudQualitySetting != cloudMode
|| mc.gameSettings.renderDistanceChunks != renderDistance)) {
|| targetDistance != renderDistance
|| cloudScaleMult != scaleMult)) {
dispose();
}
cloudMode = cloudQualitySetting;
renderDistance = mc.gameSettings.renderDistanceChunks;
renderDistance = targetDistance;
scaleMult = cloudScaleMult;
cloudElevation = mc.theWorld == null ? 128 : (int)mc.theWorld.provider.getCloudHeight();
//Allows the setting to work with RFG and similar without hardcoding.
//The minimum height check is so stuff like Aether cloud height doesn't get messed up.
if(cloudElevation >= 96) {
cloudElevation = (int)Settings.CLOUD_HEIGHT.option.getStore();
}
if (newEnabled && !isBuilt()) {
build();
@@ -269,7 +281,7 @@ public class CloudRenderer implements IResourceManagerReloadListener {
double totalOffset = cloudTicks + partialTicks;
double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks + totalOffset * 0.03;
double y = mc.theWorld.provider.getCloudHeight() - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33;
double y = cloudElevation - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33;
double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
int scale = getScale();
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.rendering;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import lombok.Getter;
import lombok.Setter;
import org.joml.Matrix4f;
import org.joml.Vector3d;
import org.lwjgl.BufferUtils;
@@ -21,6 +22,9 @@ public class RenderingState {
private final Matrix4f projectionMatrix = new Matrix4f().identity();
@Getter
private final Matrix4f modelViewMatrix = new Matrix4f().identity();
@Getter
@Setter
private float fov;
public void setCameraPosition(double x, double y, double z) {
@@ -145,6 +145,8 @@ public class RedirectorTransformer implements IClassTransformer {
.add("glGetTexParameteri")
.add("glIsEnabled")
.add("glLight")
.add("glLightf")
.add("glLighti")
.add("glLightModel")
.add("glLightModelf")
.add("glLightModeli")
@@ -40,8 +40,8 @@ public class ColorizeBlock {
private static final boolean useStemColors = MCPatcherForgeConfig.instance().ccStem;
private static final boolean useBlockColors = MCPatcherForgeConfig.instance().ccOtherBlocks;
static final boolean enableSmoothBiomes = MCPatcherForgeConfig.instance().smoothBiomes;
static final boolean enableTestColorSmoothing = MCPatcherForgeConfig.instance().testColorSmoothing;
private static final boolean enableSmoothBiomes = MCPatcherForgeConfig.instance().smoothBiomes;
private static final boolean enableTestColorSmoothing = MCPatcherForgeConfig.instance().testColorSmoothing;
private static final ResourceLocation REDSTONE_COLORS = TexturePackAPI
.newMCPatcherResourceLocation("colormap/redstone.png");
@@ -59,7 +59,8 @@ public class ColorizeBlock {
"minecraft:textures/colormap/grass.png");
private static final ResourceLocation DEFAULT_FOLIAGECOLOR = new ResourceLocation(
"minecraft:textures/colormap/foliage.png");
private static final ResourceLocation PINECOLOR = TexturePackAPI.newMCPatcherResourceLocation("colormap/pine.png");
private static final ResourceLocation PINECOLOR = TexturePackAPI
.newMCPatcherResourceLocation("colormap/pine.png");
private static final ResourceLocation BIRCHCOLOR = TexturePackAPI
.newMCPatcherResourceLocation("colormap/birch.png");
private static final ResourceLocation WATERCOLOR = TexturePackAPI
@@ -67,9 +68,6 @@ public class ColorizeBlock {
private static final String PALETTE_BLOCK_KEY = "palette.block.";
private static Block waterBlock;
private static Block staticWaterBlock;
// bitmaps from palette.block.*
private static final Map<Block, List<BlockStateMatcher>> blockColorMaps = new IdentityHashMap<>();
private static IColorMap waterColorMap;
@@ -137,9 +135,6 @@ public class ColorizeBlock {
}
static void reset() {
waterBlock = Blocks.flowing_water;
staticWaterBlock = Blocks.water;
blockColorMaps.clear();
waterColorMap = null;
resetVertexColors();
@@ -360,11 +355,10 @@ public class ColorizeBlock {
public static boolean colorizeBlock(Block block, IBlockAccess blockAccess, int x, int y, int z) {
IColorMap colorMap = findColorMap(block, blockAccess, x, y, z);
return colorizeBlock(block, blockAccess, colorMap, x, y, z);
return colorizeBlock(blockAccess, colorMap, x, y, z);
}
private static boolean colorizeBlock(Block block, IBlockAccess blockAccess, IColorMap colorMap, int x, int y,
int z) {
private static boolean colorizeBlock(IBlockAccess blockAccess, IColorMap colorMap, int x, int y, int z) {
if (colorMap == null) {
return false;
} else {
@@ -394,7 +388,7 @@ public class ColorizeBlock {
}
public static void colorizeWaterBlockGL(Block block) {
if (block == waterBlock || block == staticWaterBlock) {
if (block == Blocks.flowing_water || block == Blocks.water) {
float[] waterColor;
if (waterColorMap == null) {
waterColor = ColorizeEntity.waterBaseColor;
@@ -578,4 +572,5 @@ public class ColorizeBlock {
colorGreenTopLeft = colorGreenBottomLeft = colorGreenBottomRight = colorGreenTopRight = g;
colorBlueTopLeft = colorBlueBottomLeft = colorBlueBottomRight = colorBlueTopRight = b;
}
}
@@ -30,9 +30,7 @@ final class BlockOrientation extends RenderBlockState {
{ WEST_FACE, EAST_FACE, NORTH_FACE, SOUTH_FACE, TOP_FACE, BOTTOM_FACE, 2, -2, -2, -2, 0, 0 },
{ NORTH_FACE, SOUTH_FACE, TOP_FACE, BOTTOM_FACE, WEST_FACE, EAST_FACE, 0, 0, 0, 0, -2, -2 }, };
private int i;
private int j;
private int k;
private int x, y, z;
private int metadata;
private int altMetadata;
private int metadataBits;
@@ -46,29 +44,29 @@ final class BlockOrientation extends RenderBlockState {
@Override
public void clear() {
super.clear();
i = j = k = 0;
x = y = z = 0;
renderType = -1;
metadata = 0;
blockFace = textureFace = 0;
rotateUV = 0;
offsetsComputed = false;
haveOffsets = false;
di = dj = dk = 0;
dx = dy = dz = 0;
}
@Override
public int getI() {
return i;
public int getX() {
return x;
}
@Override
public int getJ() {
return j;
public int getY() {
return y;
}
@Override
public int getK() {
return k;
public int getZ() {
return z;
}
@Override
@@ -86,11 +84,6 @@ final class BlockOrientation extends RenderBlockState {
return textureFaceOrig;
}
@Override
public String getTextureFaceName() {
throw new UnsupportedOperationException("getTextureName");
}
@Override
public int getFaceForHV() {
return blockFace;
@@ -98,7 +91,7 @@ final class BlockOrientation extends RenderBlockState {
@Override
public boolean match(BlockStateMatcher matcher) {
return isInWorld() ? matcher.match(blockAccess, i, j, k) : matcher.match(block, metadata);
return isInWorld() ? matcher.match(blockAccess, x, y, z) : matcher.match(block, metadata);
}
@Override
@@ -113,32 +106,32 @@ final class BlockOrientation extends RenderBlockState {
}
offsetsComputed = true;
haveOffsets = false;
di = dj = dk = 0;
dx = dy = dz = 0;
switch (renderType) {
case 1 -> { // renderCrossedSquares
while (j + dj > 0 && block == blockAccess.getBlock(i, j + dj - 1, k)) {
dj--;
while (y + dy > 0 && block == blockAccess.getBlock(x, y + dy - 1, z)) {
dy--;
haveOffsets = true;
}
} // renderBlockDoor
case 7, 40 -> { // renderBlockDoublePlant
if ((metadata & 0x8) != 0 && block == blockAccess.getBlock(i, j - 1, k)) {
dj--;
if ((metadata & 0x8) != 0 && block == blockAccess.getBlock(x, y - 1, z)) {
dy--;
haveOffsets = true;
}
}
case 14 -> { // renderBlockBed
metadata = blockAccess.getBlockMetadata(i, j, k);
metadata = blockAccess.getBlockMetadata(x, y, z);
switch (metadata) {
case 0, 4 -> dk = 1; // head is one block south
case 1, 5 -> di = -1; // head is one block west
case 2, 6 -> dk = -1; // head is one block north
case 3, 7 -> di = 1; // head is one block east
case 0, 4 -> dz = 1; // head is one block south
case 1, 5 -> dx = -1; // head is one block west
case 2, 6 -> dz = -1; // head is one block north
case 3, 7 -> dx = 1; // head is one block east
default -> {
return false; // head itself, no offset
}
}
haveOffsets = block == blockAccess.getBlock(i + di, j, k + dk);
haveOffsets = block == blockAccess.getBlock(x + dx, y, z + dz);
}
default -> {
}
@@ -161,9 +154,9 @@ final class BlockOrientation extends RenderBlockState {
this.block = block;
this.blockAccess = blockAccess;
inWorld = true;
this.i = x;
this.j = y;
this.k = z;
this.x = x;
this.y = y;
this.z = z;
renderType = block.getRenderType();
metadata = altMetadata = blockAccess.getBlockMetadata(x, y, z);
offsetsComputed = false;
@@ -181,12 +174,12 @@ final class BlockOrientation extends RenderBlockState {
this.block = block;
blockAccess = null;
inWorld = false;
i = j = k = 0;
x = y = z = 0;
renderType = block.getRenderType();
blockFace = textureFace = textureFaceOrig = face;
this.metadata = metadata;
metadataBits = 1 << metadata;
di = dj = dk = 0;
dx = dy = dz = 0;
rotateUV = 0;
}
@@ -35,12 +35,12 @@ public class CTMUtils {
private static final boolean enableStandard = MCPatcherForgeConfig.instance().ctmStandard;
private static final boolean enableNonStandard = MCPatcherForgeConfig.instance().ctmNonStandard;
private static final List<ITileOverride> allOverrides = new ArrayList<>();
private static final List<TileOverride> allOverrides = new ArrayList<>();
private static final Map<Block, List<BlockStateMatcher>> blockOverrides = new IdentityHashMap<>();
private static final Map<String, List<ITileOverride>> tileOverrides = new HashMap<>();
private static final Map<String, List<TileOverride>> tileOverrides = new HashMap<>();
private static TileLoader tileLoader;
private static ITileOverride lastOverride;
private static TileOverride lastOverride;
private static final TileOverrideIterator.IJK ijkIterator = newIJKIterator();
private static final TileOverrideIterator.Metadata metadataIterator = newMetadataIterator();
@@ -94,12 +94,12 @@ public class CTMUtils {
@Override
public void afterChange() {
for (ITileOverride override : allOverrides) {
for (TileOverride override : allOverrides) {
override.registerIcons();
}
for (Map.Entry<Block, List<BlockStateMatcher>> entry : blockOverrides.entrySet()) {
for (BlockStateMatcher matcher : entry.getValue()) {
ITileOverride override = (ITileOverride) matcher.getData();
TileOverride override = (TileOverride) matcher.getData();
if (override.getRenderPass() >= 0) {
RenderPassAPI.instance.setRenderPassForBlock(entry.getKey(), override.getRenderPass());
}
@@ -107,12 +107,12 @@ public class CTMUtils {
}
for (List<BlockStateMatcher> overrides : blockOverrides.values()) {
overrides.sort((m1, m2) -> {
ITileOverride o1 = (ITileOverride) m1.getData();
ITileOverride o2 = (ITileOverride) m2.getData();
TileOverride o1 = (TileOverride) m1.getData();
TileOverride o2 = (TileOverride) m2.getData();
return o1.compareTo(o2);
});
}
for (List<ITileOverride> overrides : tileOverrides.values()) {
for (List<TileOverride> overrides : tileOverrides.values()) {
Collections.sort(overrides);
}
setBlankResource();
@@ -124,12 +124,12 @@ public class CTMUtils {
haveBlockFace = false;
}
public static synchronized IIcon getBlockIcon(IIcon icon, RenderBlocks renderBlocks, Block block, IBlockAccess blockAccess,
int i, int j, int k, int face) {
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, IBlockAccess blockAccess,
int x, int y, int z, int face) {
lastOverride = null;
if (blockAccess != null && checkFace(face)) {
if (!haveBlockFace) {
renderBlockState.setBlock(block, blockAccess, i, j, k);
renderBlockState.setBlock(block, blockAccess, x, y, z);
renderBlockState.setFace(face);
}
lastOverride = ijkIterator.go(renderBlockState, icon);
@@ -141,7 +141,7 @@ public class CTMUtils {
return lastOverride == null && skipDefaultRendering(block) ? RenderBlocksUtils.blankIcon : icon;
}
public static synchronized IIcon getBlockIcon(IIcon icon, RenderBlocks renderBlocks, Block block, int face, int metadata) {
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, int face, int metadata) {
lastOverride = null;
if (checkFace(face) && checkRenderType(block)) {
renderBlockState.setBlockMetadata(block, metadata, face);
@@ -153,8 +153,8 @@ public class CTMUtils {
return icon;
}
public static IIcon getBlockIcon(IIcon icon, RenderBlocks renderBlocks, Block block, int face) {
return getBlockIcon(icon, renderBlocks, block, face, 0);
public static IIcon getBlockIcon(IIcon icon, Block block, int face) {
return getBlockIcon(icon, block, face, 0);
}
public static void reset() {}
@@ -175,7 +175,7 @@ public class CTMUtils {
return RenderPassAPI.instance.skipDefaultRendering(block);
}
private static synchronized void registerOverride(ITileOverride override) {
private static synchronized void registerOverride(TileOverride override) {
if (override != null && !override.isDisabled()) {
boolean registered = false;
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
@@ -194,7 +194,7 @@ public class CTMUtils {
Set<String> matchingTiles = override.getMatchingTiles();
if (!MCPatcherUtils.isNullOrEmpty(matchingTiles)) {
for (String name : matchingTiles) {
List<ITileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
List<TileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
list.add(override);
logger.fine("using %s for tile %s", override, name);
registered = true;
@@ -20,28 +20,28 @@ public class GlassPaneRenderer {
private static final IIcon[] icons = new IIcon[6];
private static double u0; // left edge
private static double u1; // 7/16 point
private static double u2; // 9/16 point
private static double u3; // right edge
private static double v0; // top edge
private static double v1; // bottom edge
private static double uLeft; // left edge
private static double uLeftThin; // 7/16 point
private static double uRightThin; // 9/16 point
private static double uRight; // right edge
private static double vTop; // top edge
private static double vBottom; // bottom edge
private static double u1Scaled;
private static double u2Scaled;
public static void renderThin(RenderBlocks renderBlocks, Block blockPane, IIcon origIcon, int i, int j, int k,
public static void renderThin(RenderBlocks renderBlocks, Block blockPane, IIcon origIcon, int x, int y, int z,
boolean connectNorth, boolean connectSouth, boolean connectWest, boolean connectEast) {
if (setupIcons(renderBlocks, blockPane, origIcon, i, j, k)) {
render(i, j, k, connectNorth, connectSouth, connectWest, connectEast, 0.0, 0.0, 0.0, false);
if (setupIcons(renderBlocks, blockPane, origIcon, x, y, z)) {
render(x, y, z, connectNorth, connectSouth, connectWest, connectEast, 0.0, 0.0, 0.0, false);
}
}
public static void renderThick(RenderBlocks renderBlocks, Block blockPane, IIcon origIcon, int i, int j, int k,
public static void renderThick(RenderBlocks renderBlocks, Block blockPane, IIcon origIcon, int x, int y, int z,
boolean connectNorth, boolean connectSouth, boolean connectWest, boolean connectEast) {
if (setupIcons(renderBlocks, blockPane, origIcon, i, j, k)) {
setupPaneEdges(renderBlocks, blockPane, i, j, k);
render(i, j, k, connectNorth, connectSouth, connectWest, connectEast, 0.0625, 1.0, 0.001, true);
if (setupIcons(renderBlocks, blockPane, origIcon, x, y, z)) {
setupPaneEdges(renderBlocks.blockAccess, blockPane, x, y, z);
render(x, y, z, connectNorth, connectSouth, connectWest, connectEast, 0.0625, 1.0, 0.001, true);
}
}
@@ -52,7 +52,7 @@ public class GlassPaneRenderer {
}
for (int face = BlockOrientation.NORTH_FACE; face <= BlockOrientation.EAST_FACE; face++) {
icons[face] = CTMUtils
.getBlockIcon(origIcon, renderBlocks, blockPane, renderBlocks.blockAccess, x, y, z, face);
.getBlockIcon(origIcon, blockPane, renderBlocks.blockAccess, x, y, z, face);
if (icons[face] == null) {
skipPaneRendering = false;
return false;
@@ -63,8 +63,7 @@ public class GlassPaneRenderer {
return skipPaneRendering;
}
private static void setupPaneEdges(RenderBlocks renderBlocks, Block blockPane, int x, int y, int z) {
IBlockAccess blockAccess = renderBlocks.blockAccess;
private static void setupPaneEdges(IBlockAccess blockAccess, Block blockPane, int x, int y, int z) {
int metadata = blockAccess.getBlockMetadata(x, y, z);
skipBottomEdgeRendering = blockAccess.getBlock(x, y - 1, z) == blockPane
&& blockAccess.getBlockMetadata(x, y - 1, z) == metadata;
@@ -74,16 +73,16 @@ public class GlassPaneRenderer {
private static void render(int x, int y, int z, boolean connectNorth, boolean connectSouth, boolean connectWest,
boolean connectEast, double thickness, double uOffset, double yOffset, boolean edges) {
final double i0 = x;
final double i1 = i0 + 0.5 - thickness;
final double i2 = i0 + 0.5 + thickness;
final double i3 = i0 + 1.0;
final double j0 = y + yOffset;
final double j1 = y + 1.0 - yOffset;
final double k0 = z;
final double k1 = k0 + 0.5 - thickness;
final double k2 = k0 + 0.5 + thickness;
final double k3 = k0 + 1.0;
final double west = x;
final double westThin = x + 0.5 - thickness;
final double eastThin = x + 0.5 + thickness;
final double east = x + 1.0;
final double down = y + yOffset;
final double up = y + 1.0 - yOffset;
final double north = z;
final double northThin = z + 0.5 - thickness;
final double southThin = z + 0.5 + thickness;
final double south = z + 1.0;
u1Scaled = 8.0 - uOffset;
u2Scaled = 8.0 + uOffset;
@@ -94,149 +93,149 @@ public class GlassPaneRenderer {
if (edges) {
// east pane edge: 1/8 wide
setupTileCoords(BlockOrientation.EAST_FACE);
drawFace(i3, j1, k2, u1, v0, i3, j0, k1, u2, v1);
drawFace(east, up, southThin, uLeftThin, vTop, east, down, northThin, uRightThin, vBottom);
// west pane edge: 1/8 wide
setupTileCoords(BlockOrientation.WEST_FACE);
drawFace(i0, j1, k1, u1, v0, i0, j0, k2, u2, v1);
drawFace(west, up, northThin, uLeftThin, vTop, west, down, southThin, uRightThin, vBottom);
// south pane edge: 1/8 wide
setupTileCoords(BlockOrientation.SOUTH_FACE);
drawFace(i1, j1, k3, u1, v0, i2, j0, k3, u2, v1);
drawFace(westThin, up, south, uLeftThin, vTop, eastThin, down, south, uRightThin, vBottom);
// north pane edge: 1/8 wide
setupTileCoords(BlockOrientation.NORTH_FACE);
drawFace(i2, j1, k0, u1, v0, i1, j0, k0, u2, v1);
drawFace(eastThin, up, north, uLeftThin, vTop, westThin, down, north, uRightThin, vBottom);
}
}
if (connectEast && connectWest) {
// full west-east pane
setupTileCoords(BlockOrientation.SOUTH_FACE);
drawFace(i0, j1, k2, u0, v0, i3, j0, k2, u3, v1);
drawFace(west, up, southThin, uLeft, vTop, east, down, southThin, uRight, vBottom);
setupTileCoords(BlockOrientation.NORTH_FACE);
drawFace(i3, j1, k1, u0, v0, i0, j0, k1, u3, v1);
drawFace(east, up, northThin, uLeft, vTop, west, down, northThin, uRight, vBottom);
} else if (connectWest) {
// west half-pane
setupTileCoords(BlockOrientation.SOUTH_FACE);
if (connectSouth) {
// inner corner: 7/16 wide
drawFace(i0, j1, k2, u2, v0, i1, j0, k2, u3, v1);
drawFace(west, up, southThin, uRightThin, vTop, westThin, down, southThin, uRight, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i0, j1, k2, u1, v0, i2, j0, k2, u3, v1);
drawFace(west, up, southThin, uLeftThin, vTop, eastThin, down, southThin, uRight, vBottom);
}
setupTileCoords(BlockOrientation.NORTH_FACE);
if (connectNorth) {
// inner corner: 7/16 wide
drawFace(i1, j1, k1, u0, v0, i0, j0, k1, u1, v1);
drawFace(westThin, up, northThin, uLeft, vTop, west, down, northThin, uLeftThin, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i2, j1, k1, u0, v0, i0, j0, k1, u2, v1);
drawFace(eastThin, up, northThin, uLeft, vTop, west, down, northThin, uRightThin, vBottom);
}
if (edges && !connectNorth && !connectSouth) {
// pane edge: 1/8 wide
setupTileCoords(BlockOrientation.EAST_FACE);
drawFace(i2, j1, k2, u1, v0, i2, j0, k1, u2, v1);
drawFace(eastThin, up, southThin, uLeftThin, vTop, eastThin, down, northThin, uRightThin, vBottom);
}
} else if (connectEast) {
// east half-pane
setupTileCoords(BlockOrientation.SOUTH_FACE);
if (connectSouth) {
// inner corner: 7/16 wide
drawFace(i2, j1, k2, u0, v0, i3, j0, k2, u1, v1);
drawFace(eastThin, up, southThin, uLeft, vTop, east, down, southThin, uLeftThin, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i1, j1, k2, u0, v0, i3, j0, k2, u2, v1);
drawFace(westThin, up, southThin, uLeft, vTop, east, down, southThin, uRightThin, vBottom);
}
setupTileCoords(BlockOrientation.NORTH_FACE);
if (connectNorth) {
// inner corner: 7/16 wide
drawFace(i3, j1, k1, u2, v0, i2, j0, k1, u3, v1);
drawFace(east, up, northThin, uRightThin, vTop, eastThin, down, northThin, uRight, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i3, j1, k1, u1, v0, i1, j0, k1, u3, v1);
drawFace(east, up, northThin, uLeftThin, vTop, westThin, down, northThin, uRight, vBottom);
}
if (edges && !connectNorth && !connectSouth) {
// pane edge: 1/8 wide
setupTileCoords(BlockOrientation.WEST_FACE);
drawFace(i1, j1, k1, u1, v0, i1, j0, k2, u2, v1);
drawFace(westThin, up, northThin, uLeftThin, vTop, westThin, down, southThin, uRightThin, vBottom);
}
}
if (connectNorth && connectSouth) {
// full north-south pane
setupTileCoords(BlockOrientation.WEST_FACE);
drawFace(i1, j1, k0, u0, v0, i1, j0, k3, u3, v1);
drawFace(westThin, up, north, uLeft, vTop, westThin, down, south, uRight, vBottom);
setupTileCoords(BlockOrientation.EAST_FACE);
drawFace(i2, j1, k3, u0, v0, i2, j0, k0, u3, v1);
drawFace(eastThin, up, south, uLeft, vTop, eastThin, down, north, uRight, vBottom);
} else if (connectNorth) {
// north half-pane
setupTileCoords(BlockOrientation.WEST_FACE);
if (connectWest) {
// inner corner: 7/16 wide
drawFace(i1, j1, k0, u2, v0, i1, j0, k1, u3, v1);
drawFace(westThin, up, north, uRightThin, vTop, westThin, down, northThin, uRight, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i1, j1, k0, u1, v0, i1, j0, k2, u3, v1);
drawFace(westThin, up, north, uLeftThin, vTop, westThin, down, southThin, uRight, vBottom);
}
setupTileCoords(BlockOrientation.EAST_FACE);
if (connectEast) {
// inner corner: 7/16 wide
drawFace(i2, j1, k1, u0, v0, i2, j0, k0, u1, v1);
drawFace(eastThin, up, northThin, uLeft, vTop, eastThin, down, north, uLeftThin, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i2, j1, k2, u0, v0, i2, j0, k0, u2, v1);
drawFace(eastThin, up, southThin, uLeft, vTop, eastThin, down, north, uRightThin, vBottom);
}
if (edges && !connectWest && !connectEast) {
// pane edge: 1/8 wide
setupTileCoords(BlockOrientation.SOUTH_FACE);
drawFace(i1, j1, k2, u1, v0, i2, j0, k2, u2, v1);
drawFace(westThin, up, southThin, uLeftThin, vTop, eastThin, down, southThin, uRightThin, vBottom);
}
} else if (connectSouth) {
// south half-pane
setupTileCoords(BlockOrientation.WEST_FACE);
if (connectWest) {
// inner corner: 7/16 wide
drawFace(i1, j1, k2, u0, v0, i1, j0, k3, u1, v1);
drawFace(westThin, up, southThin, uLeft, vTop, westThin, down, south, uLeftThin, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i1, j1, k1, u0, v0, i1, j0, k3, u2, v1);
drawFace(westThin, up, northThin, uLeft, vTop, westThin, down, south, uRightThin, vBottom);
}
setupTileCoords(BlockOrientation.EAST_FACE);
if (connectEast) {
// inner corner: 7/16 wide
drawFace(i2, j1, k3, u2, v0, i2, j0, k2, u3, v1);
drawFace(eastThin, up, south, uRightThin, vTop, eastThin, down, southThin, uRight, vBottom);
} else {
// outer corner: 9/16 wide
drawFace(i2, j1, k3, u1, v0, i2, j0, k1, u3, v1);
drawFace(eastThin, up, south, uLeftThin, vTop, eastThin, down, northThin, uRight, vBottom);
}
if (edges && !connectWest && !connectEast) {
// pane edge: 1/8 wide
setupTileCoords(BlockOrientation.NORTH_FACE);
drawFace(i2, j1, k1, u1, v0, i1, j0, k1, u2, v1);
drawFace(eastThin, up, northThin, uLeftThin, vTop, westThin, down, northThin, uRightThin, vBottom);
}
}
}
private static void setupTileCoords(int face) {
IIcon icon = icons[face];
u0 = icon.getMinU();
u1 = icon.getInterpolatedU(u1Scaled);
u2 = icon.getInterpolatedU(u2Scaled);
u3 = icon.getMaxU();
v0 = icon.getMinV();
v1 = icon.getMaxV();
final IIcon icon = icons[face];
uLeft = icon.getMinU();
uLeftThin = icon.getInterpolatedU(u1Scaled);
uRightThin = icon.getInterpolatedU(u2Scaled);
uRight = icon.getMaxU();
vTop = icon.getMinV();
vBottom = icon.getMaxV();
}
private static void drawFace(double x0, double y0, double z0, double u0, double v0, // top left
@@ -248,8 +247,9 @@ public class GlassPaneRenderer {
tessellator.addVertexWithUV(x1, y0, z1, u1, v0);
}
static void clear() {
protected static void clear() {
Arrays.fill(icons, null);
skipPaneRendering = false;
}
}
@@ -1,27 +0,0 @@
package com.prupe.mcpatcher.ctm;
import java.util.List;
import java.util.Set;
import net.minecraft.util.IIcon;
import com.prupe.mcpatcher.mal.block.BlockStateMatcher;
interface ITileOverride extends Comparable<ITileOverride> {
boolean isDisabled();
void registerIcons();
List<BlockStateMatcher> getMatchingBlocks();
Set<String> getMatchingTiles();
int getRenderPass();
int getWeight();
IIcon getTileWorld(RenderBlockState renderBlockState, IIcon origIcon);
IIcon getTileHeld(RenderBlockState renderBlockState, IIcon origIcon);
}
@@ -64,9 +64,9 @@ abstract public class RenderBlockState {
protected boolean offsetsComputed;
protected boolean haveOffsets;
protected int di;
protected int dj;
protected int dk;
protected int dx;
protected int dy;
protected int dz;
final public IBlockAccess getBlockAccess() {
return blockAccess;
@@ -99,15 +99,15 @@ abstract public class RenderBlockState {
inWorld = false;
offsetsComputed = false;
haveOffsets = false;
di = dj = dk = 0;
dx = dy = dz = 0;
setFilter(null);
}
abstract public int getI();
abstract public int getX();
abstract public int getJ();
abstract public int getY();
abstract public int getK();
abstract public int getZ();
abstract public int getBlockFace();
@@ -115,8 +115,6 @@ abstract public class RenderBlockState {
abstract public int getTextureFaceOrig();
abstract public String getTextureFaceName();
abstract public int getFaceForHV();
abstract public boolean match(BlockStateMatcher matcher);
@@ -125,20 +123,20 @@ abstract public class RenderBlockState {
abstract public boolean setCoordOffsetsForRenderType();
final public int getDI() {
return di;
final public int getDX() {
return dx;
}
final public int getDJ() {
return dj;
final public int getDY() {
return dy;
}
final public int getDK() {
return dk;
final public int getDZ() {
return dz;
}
abstract public boolean shouldConnectByBlock(Block neighbor, int neighborI, int neighborJ, int neighborK);
abstract public boolean shouldConnectByBlock(Block neighbor, int neighborX, int neighborY, int neighborZ);
abstract public boolean shouldConnectByTile(Block neighbor, IIcon origIcon, int neighborI, int neighborJ,
int neighborK);
abstract public boolean shouldConnectByTile(Block neighbor, IIcon origIcon, int neighborX, int neighborY,
int neighborZ);
}
@@ -28,7 +28,7 @@ import com.prupe.mcpatcher.mal.resource.PropertiesFile;
import com.prupe.mcpatcher.mal.resource.TexturePackAPI;
import com.prupe.mcpatcher.mal.tile.TileLoader;
abstract class TileOverride implements ITileOverride {
abstract class TileOverride implements Comparable<TileOverride> {
private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
@@ -306,7 +306,6 @@ abstract class TileOverride implements ITileOverride {
return String.format("%s[%s] (%d tiles)", getMethod(), properties, getNumberOfTiles());
}
@Override
public final void registerIcons() {
icons = new IIcon[tileNames.size()];
for (int i = 0; i < icons.length; i++) {
@@ -314,17 +313,14 @@ abstract class TileOverride implements ITileOverride {
}
}
@Override
final public boolean isDisabled() {
return !properties.valid();
}
@Override
final public List<BlockStateMatcher> getMatchingBlocks() {
return matchBlocks;
}
@Override
final public Set<String> getMatchingTiles() {
if (MCPatcherUtils.isNullOrEmpty(matchTiles)) {
return null;
@@ -333,18 +329,16 @@ abstract class TileOverride implements ITileOverride {
}
}
@Override
final public int getRenderPass() {
return renderPass;
}
@Override
final public int getWeight() {
return weight;
}
@Override
public int compareTo(ITileOverride o) {
public int compareTo(TileOverride o) {
int result = o.getWeight() - getWeight();
if (result != 0) {
return result;
@@ -370,19 +364,19 @@ abstract class TileOverride implements ITileOverride {
private boolean shouldConnect(RenderBlockState renderBlockState, IIcon icon, int[] offset) {
IBlockAccess blockAccess = renderBlockState.getBlockAccess();
Block block = renderBlockState.getBlock();
int i = renderBlockState.getI();
int j = renderBlockState.getJ();
int k = renderBlockState.getK();
i += offset[0];
j += offset[1];
k += offset[2];
Block neighbor = blockAccess.getBlock(i, j, k);
int x = renderBlockState.getX();
int y = renderBlockState.getY();
int z = renderBlockState.getZ();
x += offset[0];
y += offset[1];
z += offset[2];
Block neighbor = blockAccess.getBlock(x, y, z);
if (neighbor == null) {
return false;
}
if (block == neighbor) {
BlockStateMatcher filter = renderBlockState.getFilter();
if (filter != null && !filter.match(blockAccess, i, j, k)) {
if (filter != null && !filter.match(blockAccess, x, y, z)) {
return false;
}
}
@@ -392,23 +386,22 @@ abstract class TileOverride implements ITileOverride {
int[] normal = NORMALS[blockFace];
if (!neighbor.shouldSideBeRendered(
blockAccess,
i + normal[0],
j + normal[1],
k + normal[2],
x + normal[0],
y + normal[1],
z + normal[2],
blockFace)) {
return false;
}
}
}
return switch (connectType) {
case CONNECT_BY_TILE -> renderBlockState.shouldConnectByTile(neighbor, icon, i, j, k);
case CONNECT_BY_BLOCK -> renderBlockState.shouldConnectByBlock(neighbor, i, j, k);
case CONNECT_BY_TILE -> renderBlockState.shouldConnectByTile(neighbor, icon, x, y, z);
case CONNECT_BY_BLOCK -> renderBlockState.shouldConnectByBlock(neighbor, x, y, z);
case CONNECT_BY_MATERIAL -> block.blockMaterial == neighbor.blockMaterial;
default -> false;
};
}
@Override
public final IIcon getTileWorld(RenderBlockState renderBlockState, IIcon origIcon) {
if (icons == null) {
properties.error("no images loaded, disabling");
@@ -416,9 +409,9 @@ abstract class TileOverride implements ITileOverride {
}
IBlockAccess blockAccess = renderBlockState.getBlockAccess();
Block block = renderBlockState.getBlock();
int x = renderBlockState.getI();
int y = renderBlockState.getJ();
int z = renderBlockState.getK();
int x = renderBlockState.getX();
int y = renderBlockState.getY();
int z = renderBlockState.getZ();
if (renderBlockState.getBlockFace() < 0 && requiresFace()) {
properties.warning(
"method=%s is not supported for non-standard block %s:%d @ %d %d %d",
@@ -449,7 +442,6 @@ abstract class TileOverride implements ITileOverride {
return getTileWorld_Impl(renderBlockState, origIcon);
}
@Override
public final IIcon getTileHeld(RenderBlockState renderBlockState, IIcon origIcon) {
if (icons == null) {
properties.error("no images loaded, disabling");
@@ -362,15 +362,15 @@ class TileOverrideImpl {
if (face < 0) {
face = 0;
}
int i = renderBlockState.getI();
int j = renderBlockState.getJ();
int k = renderBlockState.getK();
int x = renderBlockState.getX();
int y = renderBlockState.getY();
int z = renderBlockState.getZ();
if (linked && renderBlockState.setCoordOffsetsForRenderType()) {
i += renderBlockState.getDI();
j += renderBlockState.getDJ();
k += renderBlockState.getDK();
x += renderBlockState.getDX();
y += renderBlockState.getDY();
z += renderBlockState.getDZ();
}
long hash = WeightedIndex.hash128To64(i, j, k, face / symmetry);
long hash = WeightedIndex.hash128To64(x, y, z, face / symmetry);
int index = chooser.choose(hash);
return icons[index];
}
@@ -424,25 +424,25 @@ class TileOverrideImpl {
face = 0;
}
face &= symmetry;
int i = renderBlockState.getI();
int j = renderBlockState.getJ();
int k = renderBlockState.getK();
int x = renderBlockState.getX();
int y = renderBlockState.getY();
int z = renderBlockState.getZ();
int[] xOffset = renderBlockState.getOffset(face, REL_R);
int[] yOffset = renderBlockState.getOffset(face, REL_D);
int x = i * xOffset[0] + j * xOffset[1] + k * xOffset[2];
int y = i * yOffset[0] + j * yOffset[1] + k * yOffset[2];
int offsetX = x * xOffset[0] + y * xOffset[1] + z * xOffset[2];
int offsetY = x * yOffset[0] + y * yOffset[1] + z * yOffset[2];
if (face == NORTH_FACE || face == EAST_FACE) {
x--;
offsetX--;
}
x %= width;
if (x < 0) {
x += width;
offsetX %= width;
if (offsetX < 0) {
offsetX += width;
}
y %= height;
if (y < 0) {
y += height;
offsetY %= height;
if (offsetY < 0) {
offsetY += height;
}
return icons[width * y + x];
return icons[width * offsetY + offsetX];
}
@Override
@@ -13,28 +13,28 @@ import com.prupe.mcpatcher.mal.block.BlockStateMatcher;
import jss.notfine.config.MCPatcherForgeConfig;
abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
abstract public class TileOverrideIterator implements Iterator<TileOverride> {
private static final int MAX_RECURSION = MCPatcherForgeConfig.instance().maxRecursion;
private final Map<Block, List<BlockStateMatcher>> allBlockOverrides;
private final Map<String, List<ITileOverride>> allTileOverrides;
private final Map<String, List<TileOverride>> allTileOverrides;
protected IIcon currentIcon;
private List<BlockStateMatcher> blockOverrides;
private List<ITileOverride> tileOverrides;
private final Set<ITileOverride> skipOverrides = new HashSet<>();
private List<TileOverride> tileOverrides;
private final Set<TileOverride> skipOverrides = new HashSet<>();
private RenderBlockState renderBlockState;
private int blockPos;
private int iconPos;
private boolean foundNext;
private ITileOverride nextOverride;
private ITileOverride lastMatchedOverride;
private TileOverride nextOverride;
private TileOverride lastMatchedOverride;
protected TileOverrideIterator(Map<Block, List<BlockStateMatcher>> allBlockOverrides,
Map<String, List<ITileOverride>> allTileOverrides) {
Map<String, List<TileOverride>> allTileOverrides) {
this.allBlockOverrides = allBlockOverrides;
this.allTileOverrides = allTileOverrides;
}
@@ -72,7 +72,7 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
if (blockOverrides != null) {
while (blockPos < blockOverrides.size()) {
BlockStateMatcher matcher = blockOverrides.get(blockPos++);
if (renderBlockState.match(matcher) && checkOverride((ITileOverride) matcher.getData())) {
if (renderBlockState.match(matcher) && checkOverride((TileOverride) matcher.getData())) {
renderBlockState.setFilter(matcher);
return true;
}
@@ -82,7 +82,7 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
}
@Override
public synchronized ITileOverride next() {
public synchronized TileOverride next() {
if (!foundNext) {
throw new IllegalStateException("next called before hasNext() == true");
}
@@ -95,7 +95,7 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
throw new UnsupportedOperationException("remove not supported");
}
private synchronized boolean checkOverride(ITileOverride override) {
private synchronized boolean checkOverride(TileOverride override) {
if (override != null && !override.isDisabled() && !skipOverrides.contains(override)) {
foundNext = true;
nextOverride = override;
@@ -105,7 +105,7 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
}
}
public synchronized ITileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
public synchronized TileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
this.renderBlockState = renderBlockState;
renderBlockState.setFilter(null);
currentIcon = origIcon;
@@ -120,7 +120,7 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
pass: for (int pass = 0; pass < MAX_RECURSION; pass++) {
while (hasNext()) {
ITileOverride override = next();
TileOverride override = next();
IIcon newIcon = getTile(override, renderBlockState, origIcon);
if (newIcon != null) {
lastMatchedOverride = override;
@@ -139,28 +139,28 @@ abstract public class TileOverrideIterator implements Iterator<ITileOverride> {
return currentIcon;
}
abstract protected IIcon getTile(ITileOverride override, RenderBlockState renderBlockState, IIcon origIcon);
abstract protected IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon);
public static final class IJK extends TileOverrideIterator {
IJK(Map<Block, List<BlockStateMatcher>> blockOverrides, Map<String, List<ITileOverride>> tileOverrides) {
IJK(Map<Block, List<BlockStateMatcher>> blockOverrides, Map<String, List<TileOverride>> tileOverrides) {
super(blockOverrides, tileOverrides);
}
@Override
protected synchronized IIcon getTile(ITileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
return override.getTileWorld(renderBlockState, origIcon);
}
}
public static final class Metadata extends TileOverrideIterator {
Metadata(Map<Block, List<BlockStateMatcher>> blockOverrides, Map<String, List<ITileOverride>> tileOverrides) {
Metadata(Map<Block, List<BlockStateMatcher>> blockOverrides, Map<String, List<TileOverride>> tileOverrides) {
super(blockOverrides, tileOverrides);
}
@Override
protected synchronized IIcon getTile(ITileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
return override.getTileHeld(renderBlockState, origIcon);
}
}
@@ -49,7 +49,7 @@ public class TexturePackAPI {
public static List<IResourcePack> getResourcePacks(String namespace) {
List<IResourcePack> resourcePacks = new ArrayList<>();
IResourceManager resourceManager = getResourceManager();
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
if (resourceManager instanceof SimpleReloadableResourceManager) {
Set<Map.Entry<String, FallbackResourceManager>> entrySet = ((SimpleReloadableResourceManager) resourceManager).domainResourceManagers
.entrySet();
@@ -69,7 +69,7 @@ public class TexturePackAPI {
public static Set<String> getNamespaces() {
Set<String> namespaces = new HashSet<>();
namespaces.add(DEFAULT_NAMESPACE);
IResourceManager resourceManager = getResourceManager();
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
if (resourceManager instanceof SimpleReloadableResourceManager simpleReloadableResourceManager) {
namespaces.addAll(simpleReloadableResourceManager.domainResourceManagers.keySet());
}
@@ -307,8 +307,7 @@ public class TexturePackAPI {
}
public static void flushUnusedTextures() {
TextureManager textureManager = Minecraft.getMinecraft()
.getTextureManager();
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
if (textureManager != null) {
Set<ResourceLocation> texturesToUnload = new HashSet<>();
Set<Map.Entry<ResourceLocation, ITextureObject>> entrySet = textureManager.mapTextureObjects.entrySet();
@@ -326,8 +325,4 @@ public class TexturePackAPI {
}
}
private static IResourceManager getResourceManager() {
return Minecraft.getMinecraft()
.getResourceManager();
}
}
@@ -139,7 +139,6 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
}
}
System.gc();
long timeDiff = System.currentTimeMillis() - startTime;
Runtime runtime = Runtime.getRuntime();
long memDiff = runtime.totalMemory() - runtime.freeMemory() - startMem;
@@ -10,6 +10,7 @@ import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import jss.notfine.config.MCPatcherForgeConfig;
import jss.notfine.config.NotFineConfig;
/**
* Adapted from Hodgepodge
@@ -19,7 +20,7 @@ public enum AsmTransformers {
RENDERBLOCKS("RenderBlocks transformer", () -> AngelicaConfig.enableMCPatcherForgeFeatures
&& MCPatcherForgeConfig.instance().customColorsEnabled,
Side.CLIENT, "jss.notfine.asm.RenderBlocksTransformer"),
WORLDRENDERER("WorldRenderer transformer", () -> AngelicaConfig.enableMCPatcherForgeFeatures, Side.CLIENT,
WORLDRENDERER("WorldRenderer transformer", () -> NotFineConfig.renderPass, Side.CLIENT,
"jss.notfine.asm.WorldRendererTransformer");
private final Supplier<Boolean> applyIf;
@@ -8,34 +8,46 @@ import java.io.File;
public class NotFineConfig {
public static final String CATEGORY_GENERAL = "general";
public static final String CATEGORY_TOGGLE = "toggle";
private static final String CATEGORY_GENERAL = "general";
private static final String CATEGORY_TOGGLE = "toggle";
private static final String CATEGORY_UNFINISHED = "unfinished";
public static boolean allowAdvancedOpenGL;
public static boolean allowToggle3DAnaglyph;
public static boolean allowToggleFBO;
public static boolean betterBlockFaceCulling;
public static boolean renderPass;
public static void loadSettings() {
File configFile = new File(Launch.minecraftHome + File.separator + "config" + File.separator + NotFine.MODID + File.separator + "notfine.cfg");
Configuration notFineConfig = new Configuration(configFile);
Configuration config = new Configuration(configFile);
allowAdvancedOpenGL = notFineConfig.getBoolean("allowAdvancedOpenGL", CATEGORY_GENERAL, false,
allowAdvancedOpenGL = config.getBoolean("allowAdvancedOpenGL", CATEGORY_GENERAL, false,
"Allow Advanced OpenGL to be enabled when it might be supported.");
allowToggle3DAnaglyph = notFineConfig.getBoolean("allowToggle3DAnaglyph", CATEGORY_GENERAL, true,
allowToggle3DAnaglyph = config.getBoolean("allowToggle3DAnaglyph", CATEGORY_GENERAL, true,
"Allow 3D Anaglyph to be enabled.");
allowToggleFBO = notFineConfig.getBoolean("allowToggleFBO", CATEGORY_GENERAL, false,
allowToggleFBO = config.getBoolean("allowToggleFBO", CATEGORY_GENERAL, false,
"Allow FBOs to be disabled.");
notFineConfig.setCategoryComment(CATEGORY_TOGGLE, "Enable or disable various mod features.");
betterBlockFaceCulling = notFineConfig.getBoolean("betterBlockFaceCulling", CATEGORY_TOGGLE, true,
config.setCategoryComment(CATEGORY_TOGGLE, "Toggle mod features.");
betterBlockFaceCulling = config.getBoolean("betterBlockFaceCulling", CATEGORY_TOGGLE, true,
"Use more accurate block face culling when building chunk meshes.");
config.setCategoryComment(CATEGORY_TOGGLE, "Enable or disable various mod features.");
if(notFineConfig.hasChanged()) {
notFineConfig.save();
config.setCategoryComment(CATEGORY_UNFINISHED, "Toggle mod features that are unfinished or require compatibility improvements.");
renderPass = config.getBoolean("renderPass", CATEGORY_UNFINISHED, false,
"Allows resource pack artists to add block textures to be rendered during additional passes.");
if(config.hasChanged()) {
config.save();
}
//These will probably break hard with Angelica.
//AdvancedOpenGL even breaks hard on its own.
allowAdvancedOpenGL = false;
allowToggleFBO = false;
renderPass = false;
}
}
+25 -4
View File
@@ -1,6 +1,8 @@
package jss.notfine.core;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLightsMode;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import jss.notfine.gui.options.control.NotFineControlValueFormatter;
@@ -38,7 +40,7 @@ public enum Settings {
SettingsManager.cloudsUpdated();
}
},
CLOUD_SCALE(new NotFineOptionSlider(4, 2, 20, 1, null)),
CLOUD_SCALE(new NotFineOptionSlider(1, 1, 3, 1, null)),
DOWNFALL_DISTANCE(new NotFineOptionCycling<>(DownfallQuality.DEFAULT, OptionImpact.MEDIUM)) {
@Override
public void applyChanges() {
@@ -46,6 +48,13 @@ public enum Settings {
}
},
DYNAMIC_FOV(new NotFineOptionTickBox(true, null)),
DYNAMIC_LIGHTS(new NotFineOptionCycling(DynamicLightsMode.OFF, OptionImpact.VARIES)){
@Override
public void applyChanges() {
DynamicLights.Mode = (DynamicLightsMode) DYNAMIC_LIGHTS.option.getStore();
}
},
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
GUI_BACKGROUND(new NotFineOptionCycling<>(BackgroundSelect.DEFAULT, null)) {
@Override
public void applyChanges() {
@@ -103,7 +112,7 @@ public enum Settings {
},
PARTICLES_ENC_TABLE(new NotFineOptionSlider(1, 0, 16, 1, OptionImpact.LOW)),
PARTICLES_VOID(new NotFineOptionTickBox(true, OptionImpact.LOW)),
RENDER_DISTANCE_CLOUDS(new NotFineOptionSlider(4, 4, 64, 2, OptionImpact.VARIES)) {
RENDER_DISTANCE_CLOUDS(new NotFineOptionSlider(4, 4, 64, 1, OptionImpact.VARIES)) {
@Override
public void applyChanges() {
SettingsManager.cloudsUpdated();
@@ -163,8 +172,7 @@ public enum Settings {
@Override
public Control<Integer> getControl() {
//TODO: Don't hardcode CLOUD_SCALE check.
return new SliderControl(this, min, max, step, setting != Settings.CLOUD_SCALE ? ControlValueFormatter.number() : NotFineControlValueFormatter.multiplied(0.25f));
return new SliderControl(this, min, max, step, ControlValueFormatter.number());
}
@Override
@@ -180,6 +188,19 @@ public enum Settings {
}
}
public static class NotFineOptionSliderPercentage extends NotFineOptionSlider {
protected NotFineOptionSliderPercentage(int base, int min, int max, int step, OptionImpact impact, OptionFlag... optionFlags) {
super(base, min, max, step, impact, optionFlags);
}
@Override
public Control<Integer> getControl() {
return new SliderControl(this, min, max, step, NotFineControlValueFormatter.percentage());
}
}
public static class NotFineOptionTickBox extends NotFineOption<Boolean> {
protected NotFineOptionTickBox(boolean base, OptionImpact impact, OptionFlag... optionFlags) {
@@ -57,8 +57,8 @@ public class SettingsManager {
public static void cloudsUpdated() {
if(Settings.MODE_CLOUDS.option.getStore() != GraphicsQualityOff.OFF) {
minimumFarPlaneDistance = 32 * (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore();
minimumFarPlaneDistance += Math.abs((int)Settings.CLOUD_HEIGHT.option.getStore());
minimumFarPlaneDistance = 32 * ((int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
minimumFarPlaneDistance += (int)Settings.CLOUD_HEIGHT.option.getStore();
mc.gameSettings.clouds = true;
} else {
minimumFarPlaneDistance = 128;
@@ -190,6 +190,7 @@ public class NotFineGameOptionPages {
.add(Settings.MODE_WATER.option)
.add(Settings.DOWNFALL_DISTANCE.option)
.add(Settings.MODE_VIGNETTE.option)
.add(Settings.DYNAMIC_LIGHTS.option, AngelicaConfig.enableDynamicLights)
.add(Settings.MODE_SHADOWS.option)
.add(Settings.VOID_FOG.option)
.add(Settings.MODE_DROPPED_ITEMS.option)
@@ -205,12 +206,13 @@ public class NotFineGameOptionPages {
.add(Settings.MODE_SKY.option)
.add(Settings.MODE_SUN_MOON.option)
.add(Settings.MODE_CLOUDS.option)
//.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.CLOUD_HEIGHT.option)
//.add(Settings.CLOUD_SCALE.option)
.add(Settings.CLOUD_SCALE.option)
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
.add(Settings.MODE_STARS.option)
.add(Settings.TOTAL_STARS.option)
.add(Settings.FOG_NEAR_DISTANCE.option)
.build());
return new OptionPage(I18n.format("options.button.sky"), ImmutableList.copyOf(groups));
}
@@ -257,7 +259,7 @@ public class NotFineGameOptionPages {
.setBinding((opts, value) -> opts.anaglyph = value, opts -> opts.anaglyph)
.setImpact(OptionImpact.HIGH)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.setEnabled(NotFineConfig.allowAdvancedOpenGL)
.setEnabled(NotFineConfig.allowToggle3DAnaglyph)
.build())
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
.setName(I18n.format("options.showCape"))
@@ -4,6 +4,7 @@ import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatte
import net.minecraft.client.resources.I18n;
public class NotFineControlValueFormatter {
public static ControlValueFormatter multiplied(float multiplier) {
return (value) -> String.valueOf((value * multiplier));
}
@@ -12,4 +13,8 @@ public class NotFineControlValueFormatter {
return (v) -> (v == 0) ? I18n.format("options.off") : I18n.format((int)Math.pow(2, v) + "x");
}
public static ControlValueFormatter percentage() {
return (value) -> String.valueOf(value) + "%";
}
}
@@ -0,0 +1,64 @@
package jss.notfine.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;
/**
* Originally created by ganymedes01 for Et Futurum.
* Ported to NotFine and cleaned up by Roadhog360.
* @author ganymedes01
* @author Roadhog360
*/
@SideOnly(Side.CLIENT)
public class InterpolatedIcon extends TextureAtlasSprite {
protected int[][] interpolatedFrameData;
public InterpolatedIcon(String name) {
super(name);
}
@Override
public void updateAnimation() {
super.updateAnimation();
try {
updateAnimationInterpolated();
} catch (Exception e) {
}
}
private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException {
double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter);
int i = animationMetadata.getFrameIndex(frameCounter);
int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount();
int k = animationMetadata.getFrameIndex((frameCounter + 1) % j);
if (i != k && k >= 0 && k < framesTextureData.size()) {
int[][] aint = (int[][]) framesTextureData.get(i);
int[][] aint1 = (int[][]) framesTextureData.get(k);
if (interpolatedFrameData == null || interpolatedFrameData.length != aint.length)
interpolatedFrameData = new int[aint.length][];
for (int l = 0; l < aint.length; l++) {
if (interpolatedFrameData[l] == null)
interpolatedFrameData[l] = new int[aint[l].length];
if (l < aint1.length && aint1[l].length == aint[l].length)
for (int i1 = 0; i1 < aint[l].length; ++i1) {
int j1 = aint[l][i1];
int k1 = aint1[l][i1];
int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0));
int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0));
int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0));
interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2;
}
}
TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false);
}
}
}
+3 -35
View File
@@ -1,43 +1,11 @@
package jss.notfine.util;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import jss.notfine.gui.options.named.LeavesQuality;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
public interface ILeafBlock extends IFaceObstructionCheckHelper {
public interface ILeafBlock {
@Override()
default boolean isFaceNonObstructing(IBlockAccess worldIn, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
Block otherBlock;
otherBlock = worldIn.getBlock(x + 1, y, z);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
return true;
}
otherBlock = worldIn.getBlock(x - 1, y, z);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
return true;
}
otherBlock = worldIn.getBlock(x, y + 1, z);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
return true;
}
otherBlock = worldIn.getBlock(x, y - 1, z);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
return true;
}
otherBlock = worldIn.getBlock(x, y, z + 1);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
return true;
}
otherBlock = worldIn.getBlock(x, y, z - 1);
return !(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube());
} else {
return !SettingsManager.leavesOpaque;
}
default boolean isFullLeaf(IBlockAccess world, int x, int y, int z) {
return true;
}
}
@@ -25,12 +25,12 @@ public class LeafRenderUtil {
5, 4, 1, 0, 3, 2
};
public static boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) {
Block otherBlock = worldIn.getBlock(x, y, z);
public static boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
final Block otherBlock = world.getBlock(x, y, z);
if(otherBlock.isOpaqueCube()) {
return false;
}
if(otherBlock instanceof ILeafBlock) {
if(otherBlock instanceof ILeafBlock otherLeaf && otherLeaf.isFullLeaf(world, x, y, z)) {
switch ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()) {
case FAST, SMART -> {
return false;
@@ -40,76 +40,33 @@ public class LeafRenderUtil {
y -= Facing.offsetsYForSide[side];
z -= Facing.offsetsZForSide[side];
int renderCheck = 0;
otherBlock = worldIn.getBlock(x + 1, y, z);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
otherBlock = worldIn.getBlock(x - 1, y, z);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
otherBlock = worldIn.getBlock(x, y + 1, z);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
otherBlock = worldIn.getBlock(x, y - 1, z);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
otherBlock = worldIn.getBlock(x, y, z + 1);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
otherBlock = worldIn.getBlock(x, y, z - 1);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
renderCheck++;
}
renderCheck += ignoreWhenCulling(world, x + 1, y, z) ? 0 : 1;
renderCheck += ignoreWhenCulling(world, x - 1, y, z) ? 0 : 1;
renderCheck += ignoreWhenCulling(world, x, y + 1, z) ? 0 : 1;
renderCheck += ignoreWhenCulling(world, x, y - 1, z) ? 0 : 1;
renderCheck += ignoreWhenCulling(world, x, y, z + 1) ? 0 : 1;
renderCheck += ignoreWhenCulling(world, x, y, z - 1) ? 0 : 1;
boolean renderSide = renderCheck == 6;
if (renderSide) {
x += 2 * Facing.offsetsXForSide[side];
y += 2 * Facing.offsetsYForSide[side];
z += 2 * Facing.offsetsZForSide[side];
otherBlock = worldIn.getBlock(x, y, z);
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
if(!ignoreWhenCulling(world, x, y, z)) {
renderSide = false;
}
x -= Facing.offsetsXForSide[side];
y -= Facing.offsetsYForSide[side];
z -= Facing.offsetsZForSide[side];
int nextSide = relativeADirections[side];
otherBlock = worldIn.getBlock(
x + Facing.offsetsXForSide[nextSide],
y + Facing.offsetsYForSide[nextSide],
z + Facing.offsetsZForSide[nextSide]
);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
if(ignoreWhenCulling(world, x, y, z, relativeADirections[side])) {
return true;
}
nextSide = relativeBDirections[side];
otherBlock = worldIn.getBlock(
x + Facing.offsetsXForSide[nextSide],
y + Facing.offsetsYForSide[nextSide],
z + Facing.offsetsZForSide[nextSide]
);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
if(ignoreWhenCulling(world, x, y, z, relativeBDirections[side])) {
return true;
}
nextSide = relativeCDirections[side];
otherBlock = worldIn.getBlock(
x + Facing.offsetsXForSide[nextSide],
y + Facing.offsetsYForSide[nextSide],
z + Facing.offsetsZForSide[nextSide]
);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
if(ignoreWhenCulling(world, x, y, z, relativeCDirections[side])) {
return true;
}
nextSide = relativeDDirections[side];
otherBlock = worldIn.getBlock(
x + Facing.offsetsXForSide[nextSide],
y + Facing.offsetsYForSide[nextSide],
z + Facing.offsetsZForSide[nextSide]
);
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
if(ignoreWhenCulling(world, x, y, z, relativeDDirections[side])) {
return true;
}
}
@@ -122,9 +79,55 @@ public class LeafRenderUtil {
}
//Check for IFaceObstructionCheckHelper
if(otherBlock instanceof IFaceObstructionCheckHelper target) {
return target.isFaceNonObstructing(worldIn, x, y, z, side, 0D, 0D, 0D, 1D, 1D, 1D);
return target.isFaceNonObstructing(world, x, y, z, side, 0D, 0D, 0D, 1D, 1D, 1D);
}
return true;
}
public static boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z) {
if(Settings.MODE_LEAVES.option.getStore() != LeavesQuality.SHELLED_FAST) {
return !SettingsManager.leavesOpaque;
}
if(ignoreWhenCulling(world, x + 1, y, z)) {
return true;
}
if(ignoreWhenCulling(world, x - 1, y, z)) {
return true;
}
if(ignoreWhenCulling(world, x, y + 1, z)) {
return true;
}
if(ignoreWhenCulling(world, x, y - 1, z)) {
return true;
}
if(ignoreWhenCulling(world, x, y, z + 1)) {
return true;
}
return ignoreWhenCulling(world, x, y, z - 1);
}
public static boolean ignoreWhenCulling(IBlockAccess world, int x, int y, int z) {
Block otherBlock = world.getBlock(x, y, z);
return !(otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z) || otherBlock.isOpaqueCube());
}
public static boolean ignoreWhenCulling(IBlockAccess world, int x, int y, int z, int side) {
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
final Block otherBlock = world.getBlock(x, y, z);
return !(otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z) || otherBlock.isOpaqueCube());
}
public static boolean selectRenderMode(IBlockAccess world, int x, int y, int z, int side) {
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
final Block otherBlock = world.getBlock(x, y, z);
return otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z);
}
return SettingsManager.leavesOpaque;
}
}
@@ -81,13 +81,14 @@ public class SodiumGameOptionPages {
firstGroupBuilder.add(Settings.MODE_LIGHT_FLICKER.option)
.add(Settings.MODE_SKY.option)
.add(Settings.MODE_SUN_MOON.option)
//.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.CLOUD_HEIGHT.option)
//.add(Settings.CLOUD_SCALE.option)
.add(Settings.CLOUD_SCALE.option)
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
.add(Settings.MODE_STARS.option)
.add(Settings.TOTAL_STARS.option);
firstGroupBuilder.add(Settings.VOID_FOG.option);
.add(Settings.TOTAL_STARS.option)
.add(Settings.FOG_NEAR_DISTANCE.option)
.add(Settings.VOID_FOG.option);
groups.add(firstGroupBuilder.build());
int maxGuiScale = Math.max(3, Math.min(Minecraft.getMinecraft().displayWidth / 320, Minecraft.getMinecraft().displayHeight / 240));
@@ -221,6 +222,7 @@ public class SodiumGameOptionPages {
)*/
.add(Settings.MODE_SHADOWS.option)
.add(Settings.MODE_VIGNETTE.option)
.add(Settings.DYNAMIC_LIGHTS.option, AngelicaConfig.enableDynamicLights)
.build());
@@ -30,6 +30,12 @@ public class OptionGroup {
return this;
}
public Builder add(Option<?> option, boolean isVisible){
if (isVisible) return add(option);
return this;
}
public OptionGroup build() {
Validate.notEmpty(this.options, "At least one option must be specified");
@@ -1,6 +1,8 @@
package me.jellysquid.mods.sodium.client.model.light.data;
import com.gtnewhorizons.angelica.api.MutableBlockPos;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import me.jellysquid.mods.sodium.client.util.StateUtil;
import me.jellysquid.mods.sodium.client.world.WorldSlice;
import net.minecraft.block.Block;
@@ -119,6 +121,19 @@ public abstract class LightDataAccess {
return aoi * (1.0f / 4096.0f);
}
public static int getLightMap(long originWord, BlockPosImpl pos) {
if (!DynamicLights.isEnabled()) {
return unpackLM(originWord);
}
if (unpackFO(originWord)){
return unpackLM(originWord);
}
double dynamic = DynamicLights.get().getDynamicLightLevel(pos);
return DynamicLights.get().getLightmapWithDynamicLight(dynamic, unpackLM(originWord));
}
public WorldSlice getWorld() {
return this.world;
}
@@ -40,7 +40,7 @@ public class FlatLightPipeline implements LightPipeline {
if ((flags & ModelQuadFlags.IS_ALIGNED) != 0 || ((flags & ModelQuadFlags.IS_PARALLEL) != 0 && LightDataAccess.unpackFC(this.lightCache.get(pos)))) {
lightmap = getOffsetLightmap(pos, face);
} else {
lightmap = LightDataAccess.unpackLM(this.lightCache.get(pos));
lightmap = LightDataAccess.getLightMap(this.lightCache.get(pos), pos);
}
}
@@ -58,10 +58,10 @@ public class FlatLightPipeline implements LightPipeline {
* inconsistent values so this method exists to mirror vanilla behavior as closely as possible.
*/
private int getOffsetLightmap(BlockPosImpl pos, ForgeDirection face) {
int lightmap = LightDataAccess.unpackLM(this.lightCache.get(pos, face));
int lightmap = LightDataAccess.getLightMap(this.lightCache.get(pos, face), pos);
// If the block light is not 15 (max)...
if ((lightmap & 0xF0) != 0xF0) {
int originLightmap = LightDataAccess.unpackLM(this.lightCache.get(pos));
int originLightmap = LightDataAccess.getLightMap(this.lightCache.get(pos), pos);
// ...take the maximum combined block light at the origin and offset positions
lightmap = (lightmap & ~0xFF) | Math.max(lightmap & 0xFF, originLightmap & 0xFF);
}
@@ -6,8 +6,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackAO;
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackFO;
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackLM;
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackOP;
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.getLightMap;
class AoFaceData {
public final int[] lm = new int[4];
@@ -43,9 +43,9 @@ class AoFaceData {
// Use the origin block's light values if the adjacent one is opaque
if (offset && unpackFO(adjWord)) {
calm = unpackLM(cache.get(x, y, z));
calm = getLightMap(cache.get(x, y, z), pos);
} else {
calm = unpackLM(adjWord);
calm = getLightMap(adjWord, pos);
}
final float caao = unpackAO(adjWord);
@@ -53,22 +53,22 @@ class AoFaceData {
ForgeDirection[] faces = AoNeighborInfo.get(direction).faces;
final long e0 = cache.get(adjX, adjY, adjZ, faces[0]);
final int e0lm = unpackLM(e0);
final int e0lm = getLightMap(e0, pos);
final float e0ao = unpackAO(e0);
final boolean e0op = unpackOP(e0);
final long e1 = cache.get(adjX, adjY, adjZ, faces[1]);
final int e1lm = unpackLM(e1);
final int e1lm = getLightMap(e1, pos);
final float e1ao = unpackAO(e1);
final boolean e1op = unpackOP(e1);
final long e2 = cache.get(adjX, adjY, adjZ, faces[2]);
final int e2lm = unpackLM(e2);
final int e2lm = getLightMap(e2, pos);
final float e2ao = unpackAO(e2);
final boolean e2op = unpackOP(e2);
final long e3 = cache.get(adjX, adjY, adjZ, faces[3]);
final int e3lm = unpackLM(e3);
final int e3lm = getLightMap(e3, pos);
final float e3ao = unpackAO(e3);
final boolean e3op = unpackOP(e3);
@@ -81,7 +81,7 @@ class AoFaceData {
c0ao = e0ao;
} else {
long d0 = cache.get(adjX, adjY, adjZ, faces[0], faces[2]);
c0lm = unpackLM(d0);
c0lm = getLightMap(d0, pos);
c0ao = unpackAO(d0);
}
@@ -93,7 +93,7 @@ class AoFaceData {
c1ao = e0ao;
} else {
long d1 = cache.get(adjX, adjY, adjZ, faces[0], faces[3]);
c1lm = unpackLM(d1);
c1lm = getLightMap(d1, pos);
c1ao = unpackAO(d1);
}
@@ -106,7 +106,7 @@ class AoFaceData {
c2ao = e1ao;
} else {
long d2 = cache.get(adjX, adjY, adjZ, faces[1], faces[2]);
c2lm = unpackLM(d2);
c2lm = getLightMap(d2, pos);
c2ao = unpackAO(d2);
}
@@ -119,7 +119,7 @@ class AoFaceData {
c3ao = e1ao;
} else {
long d3 = cache.get(adjX, adjY, adjZ, faces[1], faces[3]);
c3lm = unpackLM(d3);
c3lm = getLightMap(d3, pos);
c3ao = unpackAO(d3);
}
@@ -5,7 +5,9 @@ import com.gtnewhorizons.angelica.compat.mojang.ChunkPos;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
@@ -63,6 +65,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
private int renderDistance;
private double lastCameraX, lastCameraY, lastCameraZ;
private float lastFov;
private double lastCameraPitch, lastCameraYaw;
private float lastFogDistance;
@@ -115,6 +118,9 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
// If we have a world is already loaded, unload the renderer
if (this.world != null) {
if (DynamicLights.isEnabled()){
DynamicLights.get().clearLightSources();
}
this.unloadWorld();
}
@@ -122,6 +128,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
if (world != null) {
this.loadWorld(world);
}
}
private void loadWorld(WorldClient world) {
@@ -208,8 +215,10 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
float fogDistance = FogHelper.getFogCutoff();
float fov = RenderingState.INSTANCE.getFov();
boolean dirty = pos.x != this.lastCameraX || pos.y != this.lastCameraY || pos.z != this.lastCameraZ ||
pitch != this.lastCameraPitch || yaw != this.lastCameraYaw || fogDistance != this.lastFogDistance;
pitch != this.lastCameraPitch || yaw != this.lastCameraYaw || fogDistance != this.lastFogDistance || fov != this.lastFov;
if(AngelicaConfig.enableIris) {
iris$ensureStateSwapped();
@@ -227,6 +236,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
this.lastCameraPitch = pitch;
this.lastCameraYaw = yaw;
this.lastFogDistance = fogDistance;
this.lastFov = fov;
profiler.endStartSection("chunk_update");
@@ -45,6 +45,7 @@ public class FluidRenderer {
private final QuadLightData quadLightData = new QuadLightData();
private boolean useSeparateAo;
private final int[] quadColors = new int[4];
private final TextureAtlasSprite missingTex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:missing");
public FluidRenderer(LightPipelineProvider lpp) {
int normal = Norm3b.pack(0.0f, 1.0f, 0.0f);
@@ -95,7 +96,7 @@ public class FluidRenderer {
int posZ = pos.z;
Fluid fluid = ((IFluidBlock) block).getFluid();
if(fluid == null) return false;
if (fluid == null) return false;
// Check for occluded sides; if everything is occluded, don't render
boolean sfUp = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.UP, fluid);
@@ -117,6 +118,11 @@ public class FluidRenderer {
(TextureAtlasSprite) fluid.getFlowingIcon(),
null
};
// Because some mods are wack and return null textures here
sprites[0] = sprites[0] == null ? missingTex : sprites[0];
sprites[1] = sprites[1] == null ? missingTex : sprites[1];
boolean hc = fluid.getColor() != 0xffffffff;
boolean rendered = false;
@@ -4,6 +4,7 @@ import java.util.Arrays;
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import lombok.Getter;
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
@@ -196,6 +197,10 @@ public class WorldSlice implements IBlockAccess {
blockBrightness = min;
}
if (DynamicLights.isEnabled() && !getBlock(x, y, z).isOpaqueCube()) {
return DynamicLights.get().getLightmapWithDynamicLight(x, y, z, (skyBrightness << 20 | blockBrightness << 4));
}
return skyBrightness << 20 | blockBrightness << 4;
}
@@ -10,3 +10,7 @@ public net.minecraft.client.renderer.Tessellator field_78406_i #vertexCount
public-f net.minecraft.client.settings.GameSettings$Options field_148270_M #valueStep
#For supporting some strangely setup mods
public net.minecraft.block.BlockLeaves field_150129_M
#For the interpolated icon class
public net.minecraft.client.renderer.texture.TextureAtlasSprite field_110982_k #animationMetadata
#For interpolated icon mixin
public net.minecraft.client.resources.SimpleResource field_110530_g #mcmetaJson
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more