From cfd22593c0211f5f8a925bff8034a0378e8e5db9 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 28 May 2023 15:50:39 -0500 Subject: [PATCH] Fix a few schema gen bugs --- .../animationcontrollers/States.java | 22 +++++ .../states/ParticleEffects.java | 88 +++++++++++++++++++ .../attachable/description/Scripts.java | 9 +- .../cliententity/description/Scripts.java | 41 +++++++++ .../particles/particleeffect/Components.java | 34 +++++++ .../rendercontrollers/RenderControllers.java | 35 ++++++-- .../JsonTemplateToClassConverter.java | 47 ++++++---- 7 files changed, 249 insertions(+), 27 deletions(-) create mode 100644 pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/states/ParticleEffects.java diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/States.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/States.java index 036f119..319cfbe 100644 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/States.java +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/States.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.geysermc.pack.bedrock.resource.animation_controllers.animationcontroller.animationcontrollers.states.ParticleEffects; import org.geysermc.pack.bedrock.resource.animation_controllers.animationcontroller.animationcontrollers.states.SoundEffects; import org.geysermc.pack.bedrock.resource.animation_controllers.animationcontroller.animationcontrollers.states.Variables; @@ -21,6 +22,9 @@ public class States { @SerializedName("blend_via_shortest_path") public boolean blendViaShortestPath; + @SerializedName("particle_effects") + public List particleEffects = new ArrayList<>(); + @SerializedName("sound_effects") public List soundEffects = new ArrayList<>(); @@ -64,6 +68,24 @@ public class States { this.blendViaShortestPath = blendViaShortestPath; } + /** + * The effects to be emitted. + * + * @return Particle Effects + */ + public List particleEffects() { + return this.particleEffects; + } + + /** + * The effects to be emitted. + * + * @param particleEffects Particle Effects + */ + public void particleEffects(List particleEffects) { + this.particleEffects = particleEffects; + } + /** * Collection of sounds to trigger on entry to this animation state. */ diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/states/ParticleEffects.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/states/ParticleEffects.java new file mode 100644 index 0000000..7674456 --- /dev/null +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/animation_controllers/animationcontroller/animationcontrollers/states/ParticleEffects.java @@ -0,0 +1,88 @@ +package org.geysermc.pack.bedrock.resource.animation_controllers.animationcontroller.animationcontrollers.states; + +import com.google.gson.annotations.SerializedName; +import java.lang.String; + +public class ParticleEffects { + @SerializedName("bind_to_actor") + public boolean bindToActor; + + public String effect; + + public String locator; + + @SerializedName("pre_effect_script") + public String preEffectScript; + + /** + * Set to false to have the effect spawned in the world without being bound to an actor (by default an effect is bound to the actor). + * + * @return Bind To Actor + */ + public boolean bindToActor() { + return this.bindToActor; + } + + /** + * Set to false to have the effect spawned in the world without being bound to an actor (by default an effect is bound to the actor). + * + * @param bindToActor Bind To Actor + */ + public void bindToActor(boolean bindToActor) { + this.bindToActor = bindToActor; + } + + /** + * The name of a particle effect that should be played. + * + * @return Effect + */ + public String effect() { + return this.effect; + } + + /** + * The name of a particle effect that should be played. + * + * @param effect Effect + */ + public void effect(String effect) { + this.effect = effect; + } + + /** + * The name of a locator on the actor where the effect should be located. + * + * @return Locator + */ + public String locator() { + return this.locator; + } + + /** + * The name of a locator on the actor where the effect should be located. + * + * @param locator Locator + */ + public void locator(String locator) { + this.locator = locator; + } + + /** + * A molang script that will be run when the particle emitter is initialized. + * + * @return Pre Effect Script + */ + public String preEffectScript() { + return this.preEffectScript; + } + + /** + * A molang script that will be run when the particle emitter is initialized. + * + * @param preEffectScript Pre Effect Script + */ + public void preEffectScript(String preEffectScript) { + this.preEffectScript = preEffectScript; + } +} diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/attachables/attachable/description/Scripts.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/attachables/attachable/description/Scripts.java index 51f4c90..9328a02 100644 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/attachables/attachable/description/Scripts.java +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/attachables/attachable/description/Scripts.java @@ -2,14 +2,15 @@ package org.geysermc.pack.bedrock.resource.attachables.attachable.description; import com.google.gson.annotations.SerializedName; import java.lang.String; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; import java.util.Map; /** * Scripts */ public class Scripts { - private Map animate = new HashMap<>(); + public List> animate = new ArrayList<>(); @SerializedName("parent_setup") public String parentSetup; @@ -19,14 +20,14 @@ public class Scripts { /** * @return Animate */ - public Map animate() { + public List> animate() { return this.animate; } /** * @param animate Animate */ - public void animate(Map animate) { + public void animate(List> animate) { this.animate = animate; } diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/entity/cliententity/description/Scripts.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/entity/cliententity/description/Scripts.java index 284751f..6045a95 100644 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/entity/cliententity/description/Scripts.java +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/entity/cliententity/description/Scripts.java @@ -13,6 +13,11 @@ import java.util.Map; public class Scripts { public String[] animate; + public String[] initialize; + + @SerializedName("pre_animation") + public String[] preAnimation; + @SerializedName("parent_setup") public String parentSetup; @@ -50,6 +55,42 @@ public class Scripts { this.animate = animate; } + /** + * Clientside molang variables that are to be evaluated during the creation of the entity. + * + * @return Initialize + */ + public String[] initialize() { + return this.initialize; + } + + /** + * Clientside molang variables that are to be evaluated during the creation of the entity. + * + * @param initialize Initialize + */ + public void initialize(String[] initialize) { + this.initialize = initialize; + } + + /** + * Clientside molang variables that are to be evaluated during the animation. + * + * @return Pre Animation + */ + public String[] preAnimation() { + return this.preAnimation; + } + + /** + * Clientside molang variables that are to be evaluated during the animation. + * + * @param preAnimation Pre Animation + */ + public void preAnimation(String[] preAnimation) { + this.preAnimation = preAnimation; + } + /** * @return Parent Setup */ diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/particles/particleeffect/Components.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/particles/particleeffect/Components.java index c0db684..a2b5016 100644 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/particles/particleeffect/Components.java +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/particles/particleeffect/Components.java @@ -88,6 +88,12 @@ public class Components { @SerializedName("minecraft:particle_appearance_lighting") public ParticleAppearanceLighting particleAppearanceLighting; + @SerializedName("minecraft:particle_expire_if_not_in_blocks") + public String[] particleExpireIfNotInBlocks; + + @SerializedName("minecraft:particle_expire_if_in_blocks") + public String[] particleExpireIfInBlocks; + @SerializedName("minecraft:particle_initialization") public ParticleInitialization particleInitialization; @@ -375,6 +381,34 @@ public class Components { this.particleAppearanceLighting = particleAppearanceLighting; } + /** + * @return Particle Expire If Not In Blocks Component For 1.10.0 + */ + public String[] particleExpireIfNotInBlocks() { + return this.particleExpireIfNotInBlocks; + } + + /** + * @param particleExpireIfNotInBlocks Particle Expire If Not In Blocks Component For 1.10.0 + */ + public void particleExpireIfNotInBlocks(String[] particleExpireIfNotInBlocks) { + this.particleExpireIfNotInBlocks = particleExpireIfNotInBlocks; + } + + /** + * @return Particle Expire If Not In Blocks Component For 1.10.0 + */ + public String[] particleExpireIfInBlocks() { + return this.particleExpireIfInBlocks; + } + + /** + * @param particleExpireIfInBlocks Particle Expire If Not In Blocks Component For 1.10.0 + */ + public void particleExpireIfInBlocks(String[] particleExpireIfInBlocks) { + this.particleExpireIfInBlocks = particleExpireIfInBlocks; + } + /** * @return Particle Initialization Component For 1.10.0 */ diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/render_controllers/rendercontrollers/RenderControllers.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/render_controllers/rendercontrollers/RenderControllers.java index 75ed357..7a1c329 100644 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/render_controllers/rendercontrollers/RenderControllers.java +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/render_controllers/rendercontrollers/RenderControllers.java @@ -2,7 +2,8 @@ package org.geysermc.pack.bedrock.resource.render_controllers.rendercontrollers; import com.google.gson.annotations.SerializedName; import java.lang.String; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; import java.util.Map; /** @@ -29,7 +30,7 @@ public class RenderControllers { @SerializedName("light_color_multiplier") public String lightColorMultiplier; - private Map materials = new HashMap<>(); + public List> materials = new ArrayList<>(); @SerializedName("on_fire_color") public OnFireColor onFireColor; @@ -38,7 +39,9 @@ public class RenderControllers { public OverlayColor overlayColor; @SerializedName("part_visibility") - private Map partVisibility = new HashMap<>(); + public List> partVisibility = new ArrayList<>(); + + public String[] textures; @SerializedName("uv_anim") public UvAnim uvAnim; @@ -164,7 +167,7 @@ public class RenderControllers { * * @return Materials */ - public Map materials() { + public List> materials() { return this.materials; } @@ -173,7 +176,7 @@ public class RenderControllers { * * @param materials Materials */ - public void materials(Map materials) { + public void materials(List> materials) { this.materials = materials; } @@ -218,7 +221,7 @@ public class RenderControllers { * * @return Part Visibility */ - public Map partVisibility() { + public List> partVisibility() { return this.partVisibility; } @@ -227,10 +230,28 @@ public class RenderControllers { * * @param partVisibility Part Visibility */ - public void partVisibility(Map partVisibility) { + public void partVisibility(List> partVisibility) { this.partVisibility = partVisibility; } + /** + * The texture to apply, multiple texture can be used as to create an overlay effect, a specific material is required though. + * + * @return Textures + */ + public String[] textures() { + return this.textures; + } + + /** + * The texture to apply, multiple texture can be used as to create an overlay effect, a specific material is required though. + * + * @param textures Textures + */ + public void textures(String[] textures) { + this.textures = textures; + } + /** * The UV animation to apply to the render texture. * diff --git a/pack-schema/generator/src/main/java/org/geysermc/pack/schema/converter/JsonTemplateToClassConverter.java b/pack-schema/generator/src/main/java/org/geysermc/pack/schema/converter/JsonTemplateToClassConverter.java index ee1a990..16ac347 100644 --- a/pack-schema/generator/src/main/java/org/geysermc/pack/schema/converter/JsonTemplateToClassConverter.java +++ b/pack-schema/generator/src/main/java/org/geysermc/pack/schema/converter/JsonTemplateToClassConverter.java @@ -250,7 +250,8 @@ public final class JsonTemplateToClassConverter { propertyValue, parentSchema, output, - options + options, + false ); if (altSpec != null) { spec = altSpec; @@ -346,15 +347,20 @@ public final class JsonTemplateToClassConverter { private static FieldSpec.Builder createArrayField(@NotNull String input, @NotNull String packageName, @NotNull String fieldName, @NotNull String rootClassName, @NotNull String prevClassName, @NotNull JsonObject parentSchema, @NotNull JsonObject propertyValue, @NotNull Path output, @NotNull ConverterOptions options) { FieldSpec.Builder spec = null; if (propertyValue.getValue("items") instanceof JsonObject items) { - ResolvedReference resolvedReference = flattenReference( - input, - packageName, - rootClassName, - prevClassName, - parentSchema, - items, - options - ); + ResolvedReference resolvedReference; + if (items.containsKey("$ref")) { + resolvedReference = parseRef(input, parentSchema, items); + } else { + resolvedReference = flattenReference( + input, + packageName, + rootClassName, + prevClassName, + parentSchema, + items, + options + ); + } if (resolvedReference != null) { items = resolvedReference.object(); @@ -401,7 +407,8 @@ public final class JsonTemplateToClassConverter { items, parentSchema, output, - options + options, + true ); if (altSpec != null) { @@ -454,7 +461,7 @@ public final class JsonTemplateToClassConverter { return spec; } - private static FieldSpec.Builder createObjectField(@NotNull String packageName, @NotNull String input, @NotNull String fieldName, @NotNull String rootClassName, @NotNull String prevClassName, @NotNull JsonObject propertyValue, @NotNull JsonObject parentSchema, @NotNull Path output, @NotNull ConverterOptions options) { + private static FieldSpec.Builder createObjectField(@NotNull String packageName, @NotNull String input, @NotNull String fieldName, @NotNull String rootClassName, @NotNull String prevClassName, @NotNull JsonObject propertyValue, @NotNull JsonObject parentSchema, @NotNull Path output, @NotNull ConverterOptions options, boolean arrayModifier) { String className = ConvertUtil.toClassName(fieldName); packageName = ConvertUtil.sanitizePackageName(packageName); @@ -558,10 +565,18 @@ public final class JsonTemplateToClassConverter { ClassName.get(String.class), classType); - return FieldSpec.builder(mainType, - fieldName, - Modifier.PRIVATE) - .initializer(CodeBlock.of("new $T<>()", HashMap.class)); + if (!arrayModifier) { + return FieldSpec.builder(mainType, + fieldName, + Modifier.PRIVATE) + .initializer(CodeBlock.of("new $T<>()", HashMap.class)); + } else { + ParameterizedTypeName arrayType = ParameterizedTypeName.get(ClassName.get(List.class), + mainType); + + return FieldSpec.builder(arrayType, fieldName, Modifier.PUBLIC) + .initializer(CodeBlock.of("new $T<>()", ArrayList.class)); + } } else if (propertyValue.getValue("items") instanceof JsonObject object && !object.containsKey("properties")) { ResolvedReference resolvedReference = flattenReference( input,