mirror of
https://github.com/GeyserMC/Rainbow.git
synced 2025-12-19 14:59:16 +00:00
Map animations separately from geometry
This commit is contained in:
@@ -180,10 +180,14 @@ public class BedrockItemMapper {
|
||||
}
|
||||
|
||||
// TODO Should probably get a better way to get geometry texture
|
||||
Optional<BedrockGeometryContext> bedrockGeometry = customModel.map(model -> GeometryMapper.mapGeometry(definition.textureName(), model, texture));
|
||||
String safeIdentifier = definition.textureName();
|
||||
String bone = "bone";
|
||||
Optional<BedrockGeometryContext> bedrockGeometry = customModel.map(model -> GeometryMapper.mapGeometry(safeIdentifier, bone, model, texture));
|
||||
Optional<BedrockAnimationContext> bedrockAnimation = customModel.map(model -> AnimationMapper.mapAnimation(safeIdentifier, bone, model.getTopTransforms()));
|
||||
|
||||
itemConsumer.accept(new BedrockItem(bedrockIdentifier, definition.textureName(), texture,
|
||||
AttachableMapper.mapItem(componentPatch, bedrockIdentifier, bedrockGeometry, additionalTextureConsumer), bedrockGeometry.map(BedrockGeometryContext::geometry),
|
||||
bedrockGeometry.map(BedrockGeometryContext::animation).map(BedrockAnimationContext::animation)));
|
||||
AttachableMapper.mapItem(componentPatch, bedrockIdentifier, bedrockGeometry, bedrockAnimation, additionalTextureConsumer),
|
||||
bedrockGeometry.map(BedrockGeometryContext::geometry), bedrockAnimation.map(BedrockAnimationContext::animation)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.equipment.Equippable;
|
||||
import org.geysermc.packgenerator.mapping.animation.BedrockAnimationContext;
|
||||
import org.geysermc.packgenerator.mapping.geometry.BedrockGeometryContext;
|
||||
import org.geysermc.packgenerator.mixin.EntityRenderDispatcherAccessor;
|
||||
import org.geysermc.packgenerator.pack.attachable.BedrockAttachable;
|
||||
@@ -20,7 +21,7 @@ import java.util.function.Consumer;
|
||||
public class AttachableMapper {
|
||||
|
||||
public static Optional<BedrockAttachable> mapItem(DataComponentPatch components, ResourceLocation bedrockIdentifier, Optional<BedrockGeometryContext> customGeometry,
|
||||
Consumer<ResourceLocation> textureConsumer) {
|
||||
Optional<BedrockAnimationContext> customAnimation, Consumer<ResourceLocation> textureConsumer) {
|
||||
// Crazy optional statement
|
||||
// Unfortunately we can't have both equippables and custom models, so we prefer the latter :(
|
||||
return customGeometry
|
||||
@@ -41,7 +42,7 @@ public class AttachableMapper {
|
||||
return BedrockAttachable.equipment(bedrockIdentifier, assetInfo.getFirst(), texture.getPath());
|
||||
}))
|
||||
.map(attachable -> {
|
||||
customGeometry.map(BedrockGeometryContext::animation).ifPresent(context -> {
|
||||
customAnimation.ifPresent(context -> {
|
||||
attachable.withAnimation("first_person", context.firstPerson());
|
||||
attachable.withAnimation("third_person", context.thirdPerson());
|
||||
attachable.withScript("animate", "first_person", "context.is_first_person == 1.0");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.geysermc.packgenerator.mapping.geometry;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.geysermc.packgenerator.mapping.animation.BedrockAnimationContext;
|
||||
import org.geysermc.packgenerator.pack.geometry.BedrockGeometry;
|
||||
|
||||
public record BedrockGeometryContext(BedrockGeometry geometry, BedrockAnimationContext animation, ResourceLocation texture) {}
|
||||
public record BedrockGeometryContext(BedrockGeometry geometry, ResourceLocation texture) {}
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.client.renderer.block.model.SimpleUnbakedGeometry;
|
||||
import net.minecraft.client.resources.model.ResolvedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.geysermc.packgenerator.mapping.animation.AnimationMapper;
|
||||
import org.geysermc.packgenerator.pack.geometry.BedrockGeometry;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
@@ -18,7 +17,7 @@ import java.util.Map;
|
||||
public class GeometryMapper {
|
||||
private static final Vector3fc CENTRE_OFFSET = new Vector3f(8.0F, 0.0F, 8.0F);
|
||||
|
||||
public static BedrockGeometryContext mapGeometry(String identifier, ResolvedModel model, ResourceLocation texture) {
|
||||
public static BedrockGeometryContext mapGeometry(String identifier, String boneName, ResolvedModel model, ResourceLocation texture) {
|
||||
BedrockGeometry.Builder builder = BedrockGeometry.builder(identifier);
|
||||
// Blockbench seems to always use these values
|
||||
builder.withVisibleBoundsWidth(2.0F);
|
||||
@@ -29,7 +28,7 @@ public class GeometryMapper {
|
||||
builder.withTextureWidth(16);
|
||||
builder.withTextureHeight(16);
|
||||
|
||||
BedrockGeometry.Bone.Builder bone = BedrockGeometry.bone(identifier);
|
||||
BedrockGeometry.Bone.Builder bone = BedrockGeometry.bone(boneName);
|
||||
|
||||
Vector3f min = new Vector3f(Float.MAX_VALUE);
|
||||
Vector3f max = new Vector3f(Float.MIN_VALUE);
|
||||
@@ -48,7 +47,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(), AnimationMapper.mapAnimation(identifier, identifier, model.getTopTransforms()), texture);
|
||||
return new BedrockGeometryContext(builder.withBone(bone).build(), texture);
|
||||
}
|
||||
|
||||
private static BedrockGeometry.Cube.Builder mapBlockElement(BlockElement element) {
|
||||
|
||||
Reference in New Issue
Block a user