feat: implement frame time option for cosmetics
This commit is contained in:
parent
e6ff1536e2
commit
b8cb282a62
4 changed files with 21 additions and 1 deletions
|
@ -112,7 +112,7 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
|
|||
poseStack.translate(0, 24 / 16F, 0);
|
||||
poseStack.scale(-1, -1, 1);
|
||||
|
||||
double currentTick = entityLiving.age; // TODO: Custom frametime/animation speed
|
||||
double currentTick = entityLiving.age / this.getCurrentCosmetic().getFrameTime();
|
||||
currentFrame
|
||||
= ((int) (currentTick * 1.0F)) % this.getCurrentCosmetic().getTotalFrames();
|
||||
;
|
||||
|
|
|
@ -46,4 +46,11 @@ public interface ICosmetic {
|
|||
default int getTotalFrames() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many ticks a frame of the animation should take.
|
||||
*/
|
||||
default int getFrameTime() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class RemoteCosmetic implements ICosmetic {
|
|||
private Identifier animationsLocation;
|
||||
private CosmeticParts parts = new CosmeticParts();
|
||||
private String idleAnimation = null;
|
||||
private int frameTime = 1;
|
||||
private int frameCount = 1;
|
||||
|
||||
public RemoteCosmetic(String id) {
|
||||
|
@ -61,6 +62,7 @@ public class RemoteCosmetic implements ICosmetic {
|
|||
|
||||
public void loadTexture(TextureData data) {
|
||||
this.frameCount = data.frameCount;
|
||||
this.frameTime = data.frameTime;
|
||||
this.loadedTexture = true;
|
||||
}
|
||||
|
||||
|
@ -113,4 +115,9 @@ public class RemoteCosmetic implements ICosmetic {
|
|||
public int getTotalFrames() {
|
||||
return this.frameCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrameTime() {
|
||||
return this.frameTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,13 @@ import com.google.gson.annotations.SerializedName;
|
|||
public class TextureData {
|
||||
@Expose
|
||||
public String url;
|
||||
|
||||
@Expose
|
||||
@SerializedName("total_frames")
|
||||
public int frameCount;
|
||||
|
||||
@Expose
|
||||
@SerializedName("frame_time")
|
||||
public int frameTime;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue