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