1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-19 14:59:16 +00:00

Fix some stuff

This commit is contained in:
Eclipse
2025-10-14 13:49:24 +00:00
parent 3907c2f087
commit 834b9addce
8 changed files with 33 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ public record GeyserRangeDispatchPredicate(Property property, float threshold, f
@Override
public Type type() {
return null;
return Type.RANGE_DISPATCH;
}
public interface Property {

View File

@@ -277,7 +277,7 @@ public class BedrockItemMapper {
String safeIdentifier = base.textureName();
String bone = "bone";
ResourceLocation geometryTexture = texture;
Optional<BedrockGeometryContext> bedrockGeometry = customModel.map(model -> GeometryMapper.mapGeometry(safeIdentifier, bone, model, geometryTexture));
Optional<BedrockGeometryContext> bedrockGeometry = customModel.flatMap(model -> GeometryMapper.mapGeometry(safeIdentifier, bone, model, geometryTexture));
Optional<BedrockAnimationContext> bedrockAnimation = customModel.map(model -> AnimationMapper.mapAnimation(safeIdentifier, bone, model.getTopTransforms()));
boolean exportTexture = true;

View File

@@ -5,6 +5,7 @@ import net.minecraft.client.renderer.block.model.BlockElementFace;
import net.minecraft.client.renderer.block.model.BlockElementRotation;
import net.minecraft.client.renderer.block.model.SimpleUnbakedGeometry;
import net.minecraft.client.resources.model.ResolvedModel;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import org.geysermc.rainbow.pack.geometry.BedrockGeometry;
@@ -13,11 +14,17 @@ import org.joml.Vector3f;
import org.joml.Vector3fc;
import java.util.Map;
import java.util.Optional;
public class GeometryMapper {
private static final Vector3fc CENTRE_OFFSET = new Vector3f(8.0F, 0.0F, 8.0F);
public static BedrockGeometryContext mapGeometry(String identifier, String boneName, ResolvedModel model, ResourceLocation texture) {
public static Optional<BedrockGeometryContext> mapGeometry(String identifier, String boneName, ResolvedModel model, ResourceLocation texture) {
UnbakedGeometry top = model.getTopGeometry();
if (top == UnbakedGeometry.EMPTY) {
return Optional.empty();
}
BedrockGeometry.Builder builder = BedrockGeometry.builder(identifier);
// Blockbench seems to always use these values TODO that's wrong
builder.withVisibleBoundsWidth(4.0F);
@@ -33,7 +40,7 @@ public class GeometryMapper {
Vector3f min = new Vector3f(Float.MAX_VALUE);
Vector3f max = new Vector3f(Float.MIN_VALUE);
SimpleUnbakedGeometry geometry = (SimpleUnbakedGeometry) model.getTopGeometry();
SimpleUnbakedGeometry geometry = (SimpleUnbakedGeometry) top;
for (BlockElement element : geometry.elements()) {
// TODO the origin here is wrong, some models seem to be mirrored weirdly in blockbench
BedrockGeometry.Cube cube = mapBlockElement(element).build();
@@ -48,7 +55,7 @@ public class GeometryMapper {
// Bind to the bone of the current item slot
bone.withBinding("q.item_slot_to_bone_name(context.item_slot)");
return new BedrockGeometryContext(builder.withBone(bone).build(), texture);
return Optional.of(new BedrockGeometryContext(builder.withBone(bone).build(), texture));
}
private static BedrockGeometry.Cube.Builder mapBlockElement(BlockElement element) {