Skip to content

Commit

Permalink
Fix Inconsistent Syntax on SpriteTask and bumped to full 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Mar 1, 2024
1 parent b9a4c18 commit b9b9fd9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -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
Expand Down

0 comments on commit b9b9fd9

Please sign in to comment.