Compare commits

..
Author SHA1 Message Date
Algent 267378a381 Add fast texture atlas stitcher 2026-07-09 00:19:50 +02:00
19 changed files with 408 additions and 180 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
# Description of your *PR* and other info
# Description or your *PR* and other info
<!-- Please include a summary of the change -->
<!-- Any details that you think are important to review this PR? -->
<!-- Are there any Issues / PRs related to this one? -->
@@ -1,9 +0,0 @@
package com.gtnewhorizons.angelica.api;
public interface ExtCeleritasRenderBlocks {
boolean angelica$shouldApplyCeleritasAO();
void angelica$setApplyingCeleritasAO(boolean val);
}
@@ -211,8 +211,6 @@ public enum Mixins implements IMixins {
.addClientMixins(
"rendering.MixinBlock"
, "rendering.MixinBlockFluidBase"
, "rendering.MixinBlockLiquid"
, "rendering.BlockLiquidFlowInvoker"
, "rendering.AccessorBiomeColorEvent"
, "rendering.MixinBiomeGenBase"
, "rendering.MixinChunk"
@@ -417,12 +415,6 @@ public enum Mixins implements IMixins {
.setApplyIf(() -> AngelicaConfig.removeUnicodeEvenScaling)
.addClientMixins("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
FARSEEK_WORLDSLICE_COMPAT(new MixinBuilder("Let Farseek resolve celeritas' WorldSlice so Streams' water renders properly")
.setPhase(Phase.LATE)
.addRequiredMod(TargetedMod.FARSEEK)
.setApplyIf(() -> AngelicaConfig.enableCeleritas)
.addClientMixins("client.farseek.MixinFarseekIBlockAccessValue")),
SECURITYCRAFT_COMPAT(new MixinBuilder("Fix reflection in SecurityCraft for compat with Angelica")
.setPhase(Phase.LATE)
.addRequiredMod(TargetedMod.SECURITYCRAFT)
@@ -471,7 +463,9 @@ public enum Mixins implements IMixins {
OPTIMIZE_TEXTURE_LOADING(new MixinBuilder()
.setPhase(Phase.EARLY)
.addClientMixins("angelica.textures.MixinTextureUtil_OptimizeMipmap")
.addClientMixins(
"angelica.textures.MixinTextureUtil_OptimizeMipmap",
"angelica.textures.MixinStitcher")
.setApplyIf(() -> AngelicaConfig.optimizeTextureLoading)),
REPLACE_FFP(new MixinBuilder()
@@ -17,7 +17,6 @@ public enum TargetedMod implements ITargetMod {
DRAGON_API("Reika.DragonAPI.Auxiliary.DragonAPIASMHandler", "DragonAPI"),
ET_FUTURUM_REQUIEM(null, "etfuturum"),
EXTRAUTILS(null, "ExtraUtilities"),
FARSEEK("farseek.core.FarseekCoreMod", "farseek"),
FALSETWEAKS("com.falsepattern.falsetweaks.asm.CoreLoadingPlugin", "falsetweaks"),
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
NTM_SPACE("com.hbm.dim.SolarSystem"),
@@ -0,0 +1,269 @@
package com.gtnewhorizons.angelica.textures;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.renderer.StitcherException;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.MathHelper;
public final class FastTextureStitcher {
private FastTextureStitcher() {}
public static Result stitch(Stitcher.Holder[] holders, int maxWidth, int maxHeight, boolean forcePowerOf2) {
if (holders.length == 0) {
return new Result(0, 0, Collections.<TextureAtlasSprite>emptyList());
}
long area = 0L;
int minWidth = 1;
int minHeight = 1;
boolean[] initialRotations = new boolean[holders.length];
for (int i = 0; i < holders.length; i++) {
Stitcher.Holder holder = holders[i];
initialRotations[i] = holder.isRotated();
int width = holder.getWidth();
int height = holder.getHeight();
if (width > maxWidth || height > maxHeight) {
throw unableToFit(holder, maxWidth, maxHeight);
}
area += (long) width * height;
minWidth = Math.max(minWidth, width);
minHeight = Math.max(minHeight, height);
}
int width = roundDimension(Math.max(minWidth, (int) Math.ceil(Math.sqrt(area))), forcePowerOf2);
width = Math.min(width, maxWidth);
int height = roundDimension(Math.max(minHeight, (int) ((area + width - 1L) / width)), forcePowerOf2);
height = Math.min(height, maxHeight);
while (width <= maxWidth && height <= maxHeight) {
restoreRotations(holders, initialRotations);
Result result = tryStitch(holders, width, height, forcePowerOf2);
if (result != null) {
return result;
}
if ((width <= height && width < maxWidth) || height >= maxHeight) {
width = grow(width, maxWidth, forcePowerOf2);
} else {
height = grow(height, maxHeight, forcePowerOf2);
}
}
throw unableToFit(holders[0], maxWidth, maxHeight);
}
private static Result tryStitch(Stitcher.Holder[] holders, int atlasWidth, int atlasHeight, boolean forcePowerOf2) {
List<Node> skyline = new ArrayList<>();
List<TextureAtlasSprite> sprites = new ArrayList<>(holders.length);
int[] xs = new int[holders.length];
int[] ys = new int[holders.length];
skyline.add(new Node(0, 0, atlasWidth));
int usedWidth = 0;
int usedHeight = 0;
for (int i = 0; i < holders.length; i++) {
Stitcher.Holder holder = holders[i];
Placement placement = findPlacement(skyline, atlasWidth, atlasHeight, holder);
if (placement == null) {
return null;
}
if (holder.isRotated() != placement.rotated) {
holder.rotate();
}
place(skyline, placement);
int width = holder.getWidth();
int height = holder.getHeight();
usedWidth = Math.max(usedWidth, placement.x + width);
usedHeight = Math.max(usedHeight, placement.y + height);
sprites.add(holder.getAtlasSprite());
xs[i] = placement.x;
ys[i] = placement.y;
}
int resultWidth = forcePowerOf2 ? atlasWidth : usedWidth;
int resultHeight = forcePowerOf2 ? atlasHeight : usedHeight;
for (int i = 0; i < holders.length; i++) {
Stitcher.Holder holder = holders[i];
TextureAtlasSprite sprite = holder.getAtlasSprite();
sprite.initSprite(resultWidth, resultHeight, xs[i], ys[i], holder.isRotated());
}
return new Result(resultWidth, resultHeight, sprites);
}
private static Placement findPlacement(List<Node> skyline, int atlasWidth, int atlasHeight, Stitcher.Holder holder) {
Placement best = findPlacement(skyline, atlasWidth, atlasHeight, holder.getWidth(), holder.getHeight(), holder.isRotated());
holder.rotate();
Placement rotated = findPlacement(skyline, atlasWidth, atlasHeight, holder.getWidth(), holder.getHeight(), holder.isRotated());
holder.rotate();
if (best == null) {
return rotated;
}
if (rotated == null) {
return best;
}
return rotated.bottom < best.bottom || rotated.bottom == best.bottom && rotated.x < best.x ? rotated : best;
}
private static Placement findPlacement(List<Node> skyline, int atlasWidth, int atlasHeight, int width, int height, boolean rotated) {
Placement best = null;
for (int i = 0; i < skyline.size(); i++) {
Node node = skyline.get(i);
int y = fit(skyline, i, width, height, atlasWidth, atlasHeight);
if (y >= 0) {
int bottom = y + height;
if (best == null || bottom < best.bottom || bottom == best.bottom && node.x < best.x) {
best = new Placement(i, node.x, y, width, bottom, rotated);
}
}
}
return best;
}
private static int fit(List<Node> skyline, int index, int width, int height, int atlasWidth, int atlasHeight) {
Node node = skyline.get(index);
if (node.x + width > atlasWidth) {
return -1;
}
int y = node.y;
int widthLeft = width;
for (int i = index; widthLeft > 0; i++) {
if (i >= skyline.size()) {
return -1;
}
Node current = skyline.get(i);
y = Math.max(y, current.y);
if (y + height > atlasHeight) {
return -1;
}
widthLeft -= current.width;
}
return y;
}
private static void place(List<Node> skyline, Placement placement) {
skyline.add(placement.index, new Node(placement.x, placement.bottom, placement.width));
for (int i = placement.index + 1; i < skyline.size(); i++) {
Node previous = skyline.get(i - 1);
Node current = skyline.get(i);
int shrink = previous.x + previous.width - current.x;
if (shrink <= 0) {
break;
}
current.x += shrink;
current.width -= shrink;
if (current.width <= 0) {
skyline.remove(i--);
} else {
break;
}
}
for (int i = 0; i < skyline.size() - 1; i++) {
Node current = skyline.get(i);
Node next = skyline.get(i + 1);
if (current.y == next.y) {
current.width += next.width;
skyline.remove(i-- + 1);
}
}
}
private static void restoreRotations(Stitcher.Holder[] holders, boolean[] rotations) {
for (int i = 0; i < holders.length; i++) {
if (holders[i].isRotated() != rotations[i]) {
holders[i].rotate();
}
}
}
private static int roundDimension(int value, boolean forcePowerOf2) {
return forcePowerOf2 ? MathHelper.roundUpToPowerOfTwo(value) : value;
}
private static int grow(int value, int max, boolean forcePowerOf2) {
if (value >= max) {
return max + 1;
}
int next = forcePowerOf2 ? MathHelper.roundUpToPowerOfTwo(value + 1) : value * 2;
return Math.min(Math.max(next, value + 1), max);
}
private static StitcherException unableToFit(Stitcher.Holder holder, int maxWidth, int maxHeight) {
return new StitcherException(holder, "Unable to fit: " + holder.getAtlasSprite().getIconName()
+ " - size: " + holder.getAtlasSprite().getIconWidth() + "x" + holder.getAtlasSprite().getIconHeight()
+ " - max atlas: " + maxWidth + "x" + maxHeight);
}
public static final class Result {
public final int width;
public final int height;
public final List<TextureAtlasSprite> sprites;
private Result(int width, int height, List<TextureAtlasSprite> sprites) {
this.width = width;
this.height = height;
this.sprites = sprites;
}
}
private static final class Node {
int x;
int y;
int width;
private Node(int x, int y, int width) {
this.x = x;
this.y = y;
this.width = width;
}
}
private static final class Placement {
final int index;
final int x;
final int y;
final int width;
final int bottom;
final boolean rotated;
private Placement(int index, int x, int y, int width, int bottom, boolean rotated) {
this.index = index;
this.x = x;
this.y = y;
this.width = width;
this.bottom = bottom;
this.rotated = rotated;
}
}
}
@@ -40,7 +40,6 @@ final class BlockOrientation extends RenderBlockState {
private int altMetadata;
private int metadataBits;
private int renderType;
private boolean iCtmBlock;
private int blockFace;
private int textureFace;
@@ -77,11 +76,6 @@ final class BlockOrientation extends RenderBlockState {
return z;
}
@Override
public int getMetadata() {
return metadata;
}
@Override
public int getBlockFace() {
return blockFace;
@@ -162,8 +156,8 @@ final class BlockOrientation extends RenderBlockState {
@Override
public boolean shouldConnectByBlock(Block neighbor, int neighborX, int neighborY, int neighborZ) {
return iCtmBlock ? ((ICTMBlock) block).shouldConnectByBlock(this, neighbor, neighborX, neighborY, neighborZ)
: block == neighbor && (metadataBits & (1 << blockAccess.getBlockMetadata(neighborX, neighborY, neighborZ))) != 0;
return block == neighbor
&& (metadataBits & (1 << blockAccess.getBlockMetadata(neighborX, neighborY, neighborZ))) != 0;
}
@Override
@@ -181,7 +175,6 @@ final class BlockOrientation extends RenderBlockState {
copy.altMetadata = altMetadata;
copy.metadataBits = metadataBits;
copy.renderType = renderType;
copy.iCtmBlock = iCtmBlock;
copy.blockFace = blockFace;
copy.textureFace = textureFace;
copy.textureFaceOrig = textureFaceOrig;
@@ -210,7 +203,6 @@ final class BlockOrientation extends RenderBlockState {
this.z = z;
renderType = block.getRenderType();
metadata = altMetadata = blockAccess.getBlockMetadata(x, y, z);
iCtmBlock = block instanceof ICTMBlock;
offsetsComputed = false;
}
@@ -231,7 +223,6 @@ final class BlockOrientation extends RenderBlockState {
renderType = block.getRenderType();
blockFace = textureFace = textureFaceOrig = face;
this.metadata = metadata;
iCtmBlock = block instanceof ICTMBlock;
metadataBits = 1 << metadata;
dx = dy = dz = 0;
rotateUV = 0;
@@ -9,7 +9,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.StampedLock;
import java.util.function.Consumer;
import com.github.bsideup.jabel.Desugar;
import net.minecraft.block.Block;
@@ -35,22 +34,10 @@ public class CTMUtils {
public static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
public static class Overrides {
private static class Overrides {
private final List<TileOverride> all = new ArrayList<>();
private final Map<Block, List<BlockStateMatcher>> block = new IdentityHashMap<>();
private final Map<String, List<TileOverride>> tile = new HashMap<>();
public List<TileOverride> getAll() {
return all;
}
public Map<Block, List<BlockStateMatcher>> getBlock() {
return block;
}
public Map<String, List<TileOverride>> getTile() {
return tile;
}
}
private static Overrides overrides = new Overrides();
@@ -95,8 +82,6 @@ public class CTMUtils {
private static final AtomicInteger texturePackChangeCounter = new AtomicInteger(0);
private static final ArrayList<Consumer<Overrides>> ctmRegistrationCallbacks = new ArrayList<>();
static {
try {
Class.forName(MCPatcherUtils.RENDER_PASS_CLASS)
@@ -132,9 +117,6 @@ public class CTMUtils {
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
registerOverrideWithoutLock(newOverrides, TileOverride.create(resource, tileLoader));
}
for (Consumer<Overrides> callback : ctmRegistrationCallbacks) {
callback.accept(newOverrides);
}
}
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
tileLoader.preloadTile(resource, false);
@@ -275,7 +257,7 @@ public class CTMUtils {
return RenderPassAPI.instance.skipDefaultRendering(block);
}
public static void registerOverrideWithoutLock(Overrides overrides, TileOverride override) {
private static void registerOverrideWithoutLock(Overrides overrides, TileOverride override) {
if (override != null && !override.isDisabled()) {
boolean registered = false;
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
@@ -326,8 +308,4 @@ public class CTMUtils {
private static TileOverrideIterator.Metadata newMetadataIterator() {
return new TileOverrideIterator.Metadata(overrides.block, overrides.tile);
}
public static void addCtmRegistrationCallback(Consumer<Overrides> consumer) {
ctmRegistrationCallbacks.add(consumer);
}
}
@@ -1,10 +0,0 @@
package com.prupe.mcpatcher.ctm;
import net.minecraft.block.Block;
/**
* Implement this interface on blocks that support connected textures to allow them to control if they connect to neighbors or not
*/
public interface ICTMBlock {
boolean shouldConnectByBlock(RenderBlockState renderBlockState, Block neighbor, int neighborX, int neighborY, int neighborZ);
}
@@ -109,8 +109,6 @@ abstract public class RenderBlockState {
abstract public int getZ();
abstract public int getMetadata();
abstract public int getBlockFace();
abstract public int getTextureFace();
@@ -33,7 +33,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
public final PropertiesFile properties;
protected final PropertiesFile properties;
private final String baseFilename;
protected final TileLoader tileLoader;
protected final int renderPass;
@@ -79,10 +79,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
if (properties == null) {
return null;
}
return create(properties, tileLoader);
}
public static TileOverride create(PropertiesFile properties, TileLoader tileLoader) {
String method = properties.getString("method", "default")
.toLowerCase();
TileOverride override = null;
@@ -214,7 +211,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
for (int i = 0;; i++) {
ResourceLocation resource = TileLoader
.parseTileAddress(properties.getResource(), String.valueOf(i), blankResource);
if (!TexturePackAPI.hasResource(resource) && !tileLoader.ignoreMissingTextures()) {
if (!TexturePackAPI.hasResource(resource)) {
break;
}
if (!addIcon(resource)) {
@@ -240,7 +237,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
.parseTileAddress(properties.getResource(), token, blankResource);
if (resource == null) {
tileNames.add(null);
} else if (TexturePackAPI.hasResource(resource) || tileLoader.ignoreMissingTextures()) {
} else if (TexturePackAPI.hasResource(resource)) {
addIcon(resource);
} else {
properties.warning("could not find image %s", resource);
@@ -255,7 +252,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
for (int i = from; i <= to; i++) {
ResourceLocation resource = TileLoader
.parseTileAddress(properties.getResource(), String.valueOf(i), blankResource);
if (TexturePackAPI.hasResource(resource) || tileLoader.ignoreMissingTextures()) {
if (TexturePackAPI.hasResource(resource)) {
addIcon(resource);
} else {
properties.warning("could not find image %s", resource);
@@ -9,12 +9,12 @@ import net.minecraft.util.ResourceLocation;
import com.prupe.mcpatcher.MCLogger;
import com.prupe.mcpatcher.MCPatcherUtils;
public class PropertiesFile {
final public class PropertiesFile {
protected final MCLogger logger;
protected final ResourceLocation resource;
protected final String prefix;
protected final Properties properties;
private final MCLogger logger;
private final ResourceLocation resource;
private final String prefix;
private final Properties properties;
private int errorCount;
public static PropertiesFile get(MCLogger logger, ResourceLocation resource) {
@@ -147,16 +147,4 @@ public class PropertiesFile {
return resource.equals(((PropertiesFile) that).resource);
}
}
public MCLogger getLogger() {
return logger;
}
public String getPrefix() {
return prefix;
}
public Properties getProperties() {
return properties;
}
}
@@ -275,7 +275,7 @@ public class TileLoader {
return false;
}
protected boolean registerOneIcon(TextureMap textureMap, String mapName, Map<String, TextureAtlasSprite> map) {
private boolean registerOneIcon(TextureMap textureMap, String mapName, Map<String, TextureAtlasSprite> map) {
ResourceLocation resource = tilesToRegister.iterator()
.next();
String name = resource.toString();
@@ -304,16 +304,6 @@ public class TileLoader {
return false;
}
}
TextureAtlasSprite icon = registerIconToMap(textureMap, resource, name);
map.put(name, icon);
iconMap.put(name, icon);
String extra = (width == height ? "" : ", " + (height / width) + " frames");
subLogger.finer("%s -> %s icon %dx%d%s", name, mapName, width, width, extra);
tilesToRegister.remove(resource);
return true;
}
protected TextureAtlasSprite registerIconToMap(TextureMap textureMap, ResourceLocation resource, String name) {
TextureAtlasSprite icon;
if(generatedTiles.contains(resource)){
icon = new GeneratedCTMAtlasSprite(this, textureMap.anisotropicFiltering > 1, name);
@@ -321,7 +311,12 @@ public class TileLoader {
}else{
icon = (TextureAtlasSprite)textureMap.registerIcon(name);
}
return icon;
map.put(name, icon);
iconMap.put(name, icon);
String extra = (width == height ? "" : ", " + (height / width) + " frames");
subLogger.finer("%s -> %s icon %dx%d%s", name, mapName, width, width, extra);
tilesToRegister.remove(resource);
return true;
}
public void finish() {
@@ -344,8 +339,4 @@ public class TileLoader {
public IIcon getIcon(ResourceLocation resource) {
return resource == null ? null : getIcon(resource.toString());
}
public boolean ignoreMissingTextures() {
return false;
}
}
+1 -1
View File
@@ -176,7 +176,7 @@ public enum Settings {
},
VOID_FOG(new NotFineOptionTickBox(false, OptionImpact.LOW)),
ZOOM_SMOOTH(new NotFineOptionTickBox(true, OptionImpact.LOW)),
ZOOM_SMOOTH_SPEED(new NotFineOptionSlider(20, 1, 30, 1, OptionImpact.LOW));
ZOOM_SMOOTH_SPEED(new NotFineOptionSlider(14, 1, 30, 1, OptionImpact.LOW));
public final NotFineOption<?> option;
@@ -0,0 +1,53 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.textures;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import com.gtnewhorizons.angelica.textures.FastTextureStitcher;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@Mixin(Stitcher.class)
public abstract class MixinStitcher {
@Shadow @Final private Set setStitchHolders;
@Shadow @Final private int maxWidth;
@Shadow @Final private int maxHeight;
@Shadow @Final private boolean forcePowerOf2;
@Shadow private int currentWidth;
@Shadow private int currentHeight;
@Unique private List<TextureAtlasSprite> angelica$stitchedSprites = Collections.emptyList();
/**
* @author Angelica
* @reason Use a skyline packer instead of vanilla recursive slots.
*/
@Overwrite
public void doStitch() {
Stitcher.Holder[] holders = (Stitcher.Holder[]) this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]);
Arrays.sort(holders);
FastTextureStitcher.Result result = FastTextureStitcher.stitch(holders, this.maxWidth, this.maxHeight, this.forcePowerOf2);
this.currentWidth = result.width;
this.currentHeight = result.height;
this.angelica$stitchedSprites = result.sprites;
}
/**
* @author Angelica
* @reason FastTextureStitcher initializes sprites directly.
*/
@Overwrite
public List getStichSlots() {
return new ArrayList(this.angelica$stitchedSprites);
}
}
@@ -1,14 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import net.minecraft.block.BlockLiquid;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(BlockLiquid.class)
public interface BlockLiquidFlowInvoker {
@Invoker("getFlowVector")
Vec3 angelica$getFlowVector(IBlockAccess world, int x, int y, int z);
}
@@ -1,22 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BlockLiquid.class)
public class MixinBlockLiquid {
@Redirect(
method = "getFlowDirection",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockLiquid;getFlowVector(Lnet/minecraft/world/IBlockAccess;III)Lnet/minecraft/util/Vec3;"))
private static Vec3 angelica$flowVectorOfActualBlock(BlockLiquid singleton, IBlockAccess world, int x, int y, int z) {
final Block block = world.getBlock(x, y, z);
final BlockLiquid liquid = block instanceof BlockLiquid ? (BlockLiquid) block : singleton;
return ((BlockLiquidFlowInvoker) liquid).angelica$getFlowVector(world, x, y, z);
}
}
@@ -1,6 +1,5 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import com.gtnewhorizons.angelica.api.ExtCeleritasRenderBlocks;
import com.gtnewhorizons.angelica.common.BlockError;
import com.gtnewhorizons.angelica.loading.AngelicaClientTweaker;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
@@ -34,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderBlocks.class)
public abstract class MixinRenderBlocks implements ExtCeleritasRenderBlocks {
public abstract class MixinRenderBlocks {
@Shadow
public abstract boolean renderStandardBlockWithColorMultiplier(Block p_147736_1_, int p_147736_2_, int p_147736_3_, int p_147736_4_, float p_147736_5_, float p_147736_6_, float p_147736_7_);
@@ -110,7 +109,8 @@ public abstract class MixinRenderBlocks implements ExtCeleritasRenderBlocks {
*/
@Inject(method = { "renderStandardBlockWithAmbientOcclusion", "renderStandardBlockWithAmbientOcclusionPartial" }, at = @At("HEAD"), cancellable = true)
private void handleCeleritasAo(Block block, int x, int y, int z, float r, float g, float b, CallbackInfoReturnable<Boolean> cir) {
if (angelica$shouldApplyCeleritasAO()) {
if ((this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && ClientProxy.options().quality.useCeleritasSmoothLighting) ||
(Iris.enabled && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo())) {
this.applyingCeleritasAO = true;
try {
cir.setReturnValue(this.renderStandardBlockWithColorMultiplier(block, x, y, z, r, g, b));
@@ -120,17 +120,6 @@ public abstract class MixinRenderBlocks implements ExtCeleritasRenderBlocks {
}
}
@Override
public boolean angelica$shouldApplyCeleritasAO() {
return (this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && ClientProxy.options().quality.useCeleritasSmoothLighting) ||
(Iris.enabled && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo());
}
@Override
public void angelica$setApplyingCeleritasAO(boolean val) {
this.applyingCeleritasAO = val;
}
/**
* Widen the grass identity check ({@code block != Blocks.grass}) to cover any BlockGrass subclass
* (e.g. BOP's loamy/sandy/silty grass). When the block being rendered IS a BlockGrass, we return
@@ -1,22 +0,0 @@
package com.gtnewhorizons.angelica.mixins.late.client.farseek;
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.WorldProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Pseudo
@Mixin(targets = "farseek.world.package$IBlockAccessValue$", remap = false)
public class MixinFarseekIBlockAccessValue {
@Inject(method = "worldProvider$extension", at = @At("HEAD"), cancellable = true, remap = false)
private void angelica$worldSliceProvider(IBlockAccess bac, CallbackInfoReturnable<WorldProvider> cir) {
if (bac instanceof WorldSlice slice) {
cir.setReturnValue(slice.getWorld().provider);
}
}
}
@@ -0,0 +1,58 @@
package com.gtnewhorizons.angelica.textures;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import org.junit.jupiter.api.Test;
class FastTextureStitcherTest {
@Test
void packsSpritesWithoutOverlap() {
Stitcher.Holder[] holders = {
holder("a", 32, 16),
holder("b", 16, 32),
holder("c", 16, 16),
holder("d", 8, 40),
holder("e", 24, 8)
};
Arrays.sort(holders);
FastTextureStitcher.Result result = FastTextureStitcher.stitch(holders, 128, 128, true);
assertTrue(result.width <= 128);
assertTrue(result.height <= 128);
assertEquals(holders.length, result.sprites.size());
List<Rectangle> rectangles = new ArrayList<>();
for (Stitcher.Holder holder : holders) {
TextureAtlasSprite sprite = holder.getAtlasSprite();
Rectangle rectangle = new Rectangle(sprite.getOriginX(), sprite.getOriginY(), holder.getWidth(), holder.getHeight());
assertTrue(rectangle.x >= 0);
assertTrue(rectangle.y >= 0);
assertTrue(rectangle.x + rectangle.width <= result.width);
assertTrue(rectangle.y + rectangle.height <= result.height);
for (Rectangle other : rectangles) {
assertFalse(rectangle.intersects(other), rectangle + " overlaps " + other);
}
rectangles.add(rectangle);
}
}
private static Stitcher.Holder holder(String name, int width, int height) {
TextureAtlasSprite sprite = new TextureAtlasSprite(name);
sprite.setIconWidth(width);
sprite.setIconHeight(height);
return new Stitcher.Holder(sprite, 0);
}
}