Compare commits

..
Author SHA1 Message Date
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
57 changed files with 1321 additions and 232 deletions

No files matched your search

+3
View File
@@ -65,3 +65,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
+5
View File
@@ -75,6 +75,8 @@ 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 }
@@ -97,6 +99,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'))
@@ -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);
@@ -16,6 +16,7 @@ public class ModStatus {
*/
public static boolean isOldNEIDLoaded;
public static boolean isBetterCrashesLoaded;
public static boolean isNEIDMetadataExtended;
public static boolean isLotrLoaded;
public static boolean isChunkAPILoaded;
@@ -24,6 +25,7 @@ public class ModStatus {
public static boolean isHoloInventoryLoaded;
public static void preInit(){
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
isNEIDLoaded = Loader.isModLoaded("neid");
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
isLotrLoaded = Loader.isModLoaded("lotr");
@@ -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();
}
}
@@ -70,7 +70,6 @@ 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.DefaultBoolean(true)
@Config.RequiresMcRestart
@@ -81,6 +80,11 @@ public class AngelicaConfig {
@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
@@ -0,0 +1,363 @@
package com.gtnewhorizons.angelica.dynamiclights;
import com.gtnewhorizons.angelica.api.BlockPos;
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 net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
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 java.util.HashSet;
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, BlockPos.unpackLongX(chunkPos), BlockPos.unpackLongY(chunkPos), BlockPos.unpackLongZ(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) {
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) {
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.isInWater());
}
if (entity instanceof EntityLivingBase living) {
int luminance = 0;
boolean inWater = living.isInWater();
// check equipment + hand for light
ItemStack itemStack;
for (int i = 0; i < 5; i++) {
if ((itemStack = living.getEquipmentInSlot(i)) != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack, 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);
}
@@ -105,7 +105,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();
@@ -125,6 +124,19 @@ public class GLStateManager {
@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;
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
@@ -54,6 +53,14 @@ 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"
)
),
// 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)
@@ -272,6 +279,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 +304,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 +341,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 +412,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 +437,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 +447,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 +549,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;
@@ -21,9 +21,11 @@ public enum TargetedMod {
, 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")
;
@@ -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;
}
}
@@ -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;
}
}
@@ -2,5 +2,6 @@ package com.gtnewhorizons.angelica.mixins.interfaces;
public interface IRenderGlobalExt {
void scheduleTerrainUpdate();
void reload();
}
@@ -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;
@@ -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,10 +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,
private static boolean colorizeBlock(IBlockAccess blockAccess, IColorMap colorMap, int x, int y,
int z) {
if (colorMap == null) {
return false;
@@ -394,7 +389,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 +573,5 @@ public class ColorizeBlock {
colorGreenTopLeft = colorGreenBottomLeft = colorGreenBottomRight = colorGreenTopRight = g;
colorBlueTopLeft = colorBlueBottomLeft = colorBlueBottomRight = colorBlueTopRight = b;
}
}
@@ -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;
}
}
@@ -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;
@@ -46,6 +48,12 @@ 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();
}
},
GUI_BACKGROUND(new NotFineOptionCycling<>(BackgroundSelect.DEFAULT, null)) {
@Override
public void applyChanges() {
@@ -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)
.add(Settings.MODE_SHADOWS.option)
.add(Settings.VOID_FOG.option)
.add(Settings.MODE_DROPPED_ITEMS.option)
@@ -257,7 +258,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"))
+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;
}
}
@@ -221,6 +221,7 @@ public class SodiumGameOptionPages {
)*/
.add(Settings.MODE_SHADOWS.option)
.add(Settings.MODE_VIGNETTE.option)
.add(Settings.DYNAMIC_LIGHTS.option)
.build());
@@ -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,6 +5,7 @@ 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 it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -115,6 +116,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 +126,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
if (world != null) {
this.loadWorld(world);
}
}
private void loadWorld(WorldClient world) {
@@ -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;
}
@@ -17,6 +17,8 @@ options.guiScale.massive=Massive
options.downfall_distance=Weather Effects
options.dynamic_fov=Dynamic FOV
options.dynamic_fov.tooltip=If enabled, the game's field of view will change based on the player's speed.
options.dynamic_lights=Dynamic Lights
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - no delay
options.mode_cloud_translucency=Cloud Translucency
options.mode_clouds=Clouds
options.mode_dropped_items=Dropped Items