diff --git a/common/src/main/java/org/figuramc/figura/model/rendertasks/SpriteTask.java b/common/src/main/java/org/figuramc/figura/model/rendertasks/SpriteTask.java index 0c0ea2c81..d219f409b 100644 --- a/common/src/main/java/org/figuramc/figura/model/rendertasks/SpriteTask.java +++ b/common/src/main/java/org/figuramc/figura/model/rendertasks/SpriteTask.java @@ -120,40 +120,51 @@ public String getTexture() { @LuaMethodOverload( argumentTypes = {FiguraTexture.class, Integer.class, Integer.class}, argumentNames = {"texture", "width", "height"} + ), + @LuaMethodOverload( + argumentTypes = {String.class, FiguraVec2.class}, + argumentNames = {"textureLocation", "dimensions"} + ), + @LuaMethodOverload( + argumentTypes = {FiguraTexture.class, FiguraVec2.class}, + argumentNames = {"texture", "dimensions"} ) }, aliases = "texture", value = "sprite_task.set_texture" ) - public SpriteTask setTexture(Object texture, Integer width, Integer height) { + public SpriteTask setTexture(Object texture, Object width, Integer height) { if (texture == null) { this.texture = null; return this; } - + FiguraVec2 dimensions = LuaUtils.parseVec2("setTexture", width, height); + if (width == null || height == null ){ + dimensions = null; + } if (texture instanceof String s) { try { this.texture = new ResourceLocation(s); } catch (Exception e) { this.texture = MissingTextureAtlasSprite.getLocation(); } - if (width == null || height == null) + if (dimensions == null) throw new LuaError("Texture dimensions cannot be null"); } else if (texture instanceof FiguraTexture tex) { this.texture = tex.getLocation(); - if (width == null || height == null) { + if (dimensions == null) { width = tex.getWidth(); height = tex.getHeight(); } } else { throw new LuaError("Illegal argument to setTexture(): " + texture.getClass().getSimpleName()); } - - if (width <= 0 || height <= 0) - throw new LuaError("Invalid texture size: " + width + "x" + height); - - this.textureW = this.regionW = this.width = width; - this.textureH = this.regionH = this.height = height; + if (dimensions != null && (dimensions.x <= 0 || dimensions.y <= 0)) + throw new LuaError("Invalid texture size: " + width + "x" + height); + if (dimensions != null) { + this.textureW = this.regionW = this.width = (int) Math.round(dimensions.x); + this.textureH = this.regionH = this.height = (int) Math.round(dimensions.y); + } recalculateVertices(); return this; } diff --git a/gradle.properties b/gradle.properties index 57542dd61..d1fe1b72d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ mappings = 1 enabled_platforms = fabric,forge # Mod Properties -mod_version = 0.1.3-pre.5 +mod_version = 0.1.3 maven_group = org.figuramc archives_base_name = figura assets_version = v2