Athena support + stair improvements + coloration #5
@ -8,7 +8,7 @@ yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.6
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.1
|
||||
mod_version = 1.2
|
||||
maven_group = fr.adrien1106
|
||||
archives_base_name = ReFramed
|
||||
mod_id = reframed
|
||||
|
@ -25,7 +25,7 @@ import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* TODO handle grass side, multiple camos
|
||||
* TODO multiple camos
|
||||
*/
|
||||
public class ReFramed implements ModInitializer {
|
||||
public static final String MODID = "reframed";
|
||||
|
@ -145,8 +145,7 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
||||
protected final CamoAppearance ta;
|
||||
|
||||
public int transform(QuadEmitter quad, int i) {
|
||||
int tag = quad.tag();
|
||||
if(tag == 0) return 0; //Pass the quad through unmodified.
|
||||
if(quad.tag() == 0) return 0; //Pass the quad through unmodified.
|
||||
|
||||
Direction direction = quad.nominalFace();
|
||||
List<SpriteProperties> sprites = ta.getSprites(direction, seed);
|
||||
@ -164,6 +163,7 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
||||
| properties.flags()
|
||||
| (uvlock ? MutableQuadView.BAKE_LOCK_UV : 0)
|
||||
);
|
||||
quad.tag(i+1);
|
||||
quad.emit();
|
||||
return i;
|
||||
}
|
||||
@ -180,6 +180,7 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
||||
MutableQuadView.BAKE_NORMALIZED
|
||||
| MutableQuadView.BAKE_LOCK_UV
|
||||
);
|
||||
quad.tag(i+1);
|
||||
quad.emit();
|
||||
return i;
|
||||
}
|
||||
@ -198,10 +199,9 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
||||
|
||||
@Override
|
||||
public boolean transform(MutableQuadView quad) {
|
||||
int tag = quad.tag();
|
||||
if(tag == 0) return true;
|
||||
if(quad.tag() == 0) return true;
|
||||
|
||||
if(ta.hasColor(quad.nominalFace(), seed)) quad.color(tint, tint, tint, tint);
|
||||
if(ta.hasColor(quad.nominalFace(), seed, quad.tag())) quad.color(tint, tint, tint, tint);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5,4 +5,4 @@ import net.minecraft.util.math.Direction;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public record Appearance(Map<Direction, List<SpriteProperties>> sprites, byte color_mask) {}
|
||||
public record Appearance(Map<Direction, List<SpriteProperties>> sprites) {}
|
||||
|
@ -9,5 +9,5 @@ import java.util.List;
|
||||
public interface CamoAppearance {
|
||||
@NotNull RenderMaterial getRenderMaterial(boolean ao);
|
||||
@NotNull List<SpriteProperties> getSprites(Direction dir, long seed);
|
||||
boolean hasColor(Direction dir, long seed);
|
||||
boolean hasColor(Direction dir, long seed, int index);
|
||||
}
|
||||
|
@ -119,7 +119,6 @@ public class CamoAppearanceManager {
|
||||
Random random = Random.create();
|
||||
|
||||
Map<Direction, List<SpriteProperties>> sprites = new EnumMap<>(Direction.class);
|
||||
byte[] color_mask = {0b000000};
|
||||
|
||||
//Read quads off the model by their `cullface`
|
||||
Arrays.stream(Direction.values()).forEach(direction -> {
|
||||
@ -131,19 +130,22 @@ public class CamoAppearanceManager {
|
||||
|
||||
sprites.put(direction, new ArrayList<>());
|
||||
quads.forEach(quad -> {
|
||||
if(quad.hasColor()) color_mask[0] |= (byte) (1 << direction.ordinal());
|
||||
|
||||
Sprite sprite = quad.getSprite();
|
||||
if(sprite == null) return;
|
||||
sprites.compute(direction, (dir, pairs) -> {
|
||||
sprites.computeIfPresent(direction, (dir, pairs) -> {
|
||||
quad_emitter.fromVanilla(quad, material, direction);
|
||||
pairs.add(new SpriteProperties(sprite, getBakeFlags(quad_emitter, sprite), QuadPosBounds.read(quad_emitter)));
|
||||
pairs.add(new SpriteProperties(
|
||||
sprite,
|
||||
getBakeFlags(quad_emitter, sprite),
|
||||
QuadPosBounds.read(quad_emitter),
|
||||
quad.hasColor())
|
||||
);
|
||||
return pairs;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return new Appearance(sprites, color_mask[0]);
|
||||
return new Appearance(sprites);
|
||||
}
|
||||
|
||||
private static int getBakeFlags(QuadEmitter emitter, Sprite sprite) {
|
||||
|
@ -31,8 +31,10 @@ public class ComputedAppearance implements CamoAppearance {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasColor(Direction dir, long seed) {
|
||||
return (appearance.color_mask() & (1 << dir.ordinal())) != 0;
|
||||
public boolean hasColor(Direction dir, long seed, int index) {
|
||||
List<SpriteProperties> properties = getSprites(dir, seed);
|
||||
if (index != 0) index = properties.size() - index;
|
||||
return properties.get(index).has_colors();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,11 +25,11 @@ public class SingleSpriteAppearance implements CamoAppearance {
|
||||
|
||||
@Override
|
||||
public @NotNull List<SpriteProperties> getSprites(Direction dir, long seed) {
|
||||
return List.of(new SpriteProperties(defaultSprite, 0, null));
|
||||
return List.of(new SpriteProperties(defaultSprite, 0, null, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasColor(Direction dir, long seed) {
|
||||
public boolean hasColor(Direction dir, long seed, int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,5 +3,5 @@ package fr.adrien1106.reframed.client.model.apperance;
|
||||
import fr.adrien1106.reframed.client.model.QuadPosBounds;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
|
||||
public record SpriteProperties(Sprite sprite, int flags, QuadPosBounds bounds) {
|
||||
public record SpriteProperties(Sprite sprite, int flags, QuadPosBounds bounds, boolean has_colors) {
|
||||
}
|
||||
|
@ -50,8 +50,10 @@ public class WeightedComputedAppearance implements CamoAppearance {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasColor(Direction dir, long seed) {
|
||||
return (getAppearance(seed).color_mask() & (1 << dir.ordinal())) != 0;
|
||||
public boolean hasColor(Direction dir, long seed, int index) {
|
||||
List<SpriteProperties> properties = getSprites(dir, seed);
|
||||
if (index != 0) index = properties.size() - index;
|
||||
return properties.get(index).has_colors();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user