diff --git a/src/main/java/com/mraof/minestuck/client/gui/DialogueButton.java b/src/main/java/com/mraof/minestuck/client/gui/DialogueButton.java index 03ae793c84..e89a98351f 100644 --- a/src/main/java/com/mraof/minestuck/client/gui/DialogueButton.java +++ b/src/main/java/com/mraof/minestuck/client/gui/DialogueButton.java @@ -3,16 +3,16 @@ import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.FormattedCharSequence; -import net.minecraftforge.client.gui.widget.ExtendedButton; import java.util.List; @MethodsReturnNonnullByDefault -public class DialogueButton extends ExtendedButton +public class DialogueButton extends Button { public static final int TEXT_SPACING = 9; public static final int NORMAL_DEFAULT_HEIGHT = 17; @@ -25,7 +25,7 @@ public class DialogueButton extends ExtendedButton public DialogueButton(ResourceLocation gui, boolean isResponse, int xPos, int yPos, int width, int defaultHeight, Component displayString, OnPress handler) { - super(xPos, yPos, width, defaultHeight, displayString, handler); + super(xPos, yPos, width, defaultHeight, displayString, handler, DEFAULT_NARRATION); this.gui = gui; this.isResponse = isResponse; diff --git a/src/main/java/com/mraof/minestuck/client/gui/DialogueScreen.java b/src/main/java/com/mraof/minestuck/client/gui/DialogueScreen.java index 6391539739..3e3842e8c2 100644 --- a/src/main/java/com/mraof/minestuck/client/gui/DialogueScreen.java +++ b/src/main/java/com/mraof/minestuck/client/gui/DialogueScreen.java @@ -199,10 +199,8 @@ private void renderAnimation(GuiGraphics guiGraphics) int moddedHeight = (int) (animationData.spriteHeight() * scale); //if there is a .png.mcmeta file associated with the sprite, the animation for it is updated here - AnimatableTexture.setAndUpdate(sprite, animationTick); + AnimatableTexture.setAndUpdate(sprite, animationTick++); guiGraphics.blit(sprite, xOffset + GUI_WIDTH + animationData.xOffset(), (this.height / 2) - (animationData.spriteHeight() / 2), 0, 0, moddedWidth, moddedHeight, moddedWidth, moddedHeight); - - animationTick++; } @Override diff --git a/src/main/java/com/mraof/minestuck/data/dialogue/DialogueProvider.java b/src/main/java/com/mraof/minestuck/data/dialogue/DialogueProvider.java index 217f05f926..961b07047f 100644 --- a/src/main/java/com/mraof/minestuck/data/dialogue/DialogueProvider.java +++ b/src/main/java/com/mraof/minestuck/data/dialogue/DialogueProvider.java @@ -164,9 +164,9 @@ public NodeBuilder addDescription(MessageProducer message) return this; } - public NodeBuilder animation(DialogueAnimationData.Emotion emotion) + public NodeBuilder animation(String emotion) { - return animation(new DialogueAnimationData(emotion.getSerializedName(), DialogueAnimationData.DEFAULT_SPRITE_HEIGHT, DialogueAnimationData.DEFAULT_SPRITE_WIDTH, 0, 0, 1.0F)); + return animation(new DialogueAnimationData(emotion, DialogueAnimationData.DEFAULT_SPRITE_HEIGHT, DialogueAnimationData.DEFAULT_SPRITE_WIDTH, 0, 0, 1.0F)); } public NodeBuilder animation(DialogueAnimationData animation) diff --git a/src/main/java/com/mraof/minestuck/entity/dialogue/DialogueAnimationData.java b/src/main/java/com/mraof/minestuck/entity/dialogue/DialogueAnimationData.java index b36a253b59..6ac0d9e5c7 100644 --- a/src/main/java/com/mraof/minestuck/entity/dialogue/DialogueAnimationData.java +++ b/src/main/java/com/mraof/minestuck/entity/dialogue/DialogueAnimationData.java @@ -16,13 +16,18 @@ public record DialogueAnimationData(String emotion, int spriteHeight, int spriteWidth, int xOffset, int yOffset, float scale) { + public static final String GENERIC_EMOTION = "generic"; + public static final String PLEASED_EMOTION = "pleased"; + public static final String UPSET_EMOTION = "upset"; + public static final String SCARED_EMOTION = "scared"; + public static final int DEFAULT_SPRITE_WIDTH = 128; public static final int DEFAULT_SPRITE_HEIGHT = 128; - public static final DialogueAnimationData DEFAULT_ANIMATION = new DialogueAnimationData(Emotion.GENERIC.getSerializedName(), DEFAULT_SPRITE_HEIGHT, DEFAULT_SPRITE_WIDTH, 0, 0, 1.0F); + public static final DialogueAnimationData DEFAULT_ANIMATION = new DialogueAnimationData(GENERIC_EMOTION, DEFAULT_SPRITE_HEIGHT, DEFAULT_SPRITE_WIDTH, 0, 0, 1.0F); public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - PreservingOptionalFieldCodec.withDefault(Codec.STRING, "emotion", Emotion.GENERIC.getSerializedName()).forGetter(DialogueAnimationData::emotion), + PreservingOptionalFieldCodec.withDefault(Codec.STRING, "emotion", GENERIC_EMOTION).forGetter(DialogueAnimationData::emotion), PreservingOptionalFieldCodec.withDefault(Codec.INT, "height", DEFAULT_SPRITE_HEIGHT).forGetter(DialogueAnimationData::spriteHeight), PreservingOptionalFieldCodec.withDefault(Codec.INT, "width", DEFAULT_SPRITE_WIDTH).forGetter(DialogueAnimationData::spriteWidth), PreservingOptionalFieldCodec.withDefault(Codec.INT, "x_offset", 0).forGetter(DialogueAnimationData::xOffset), @@ -65,7 +70,7 @@ public ResourceLocation getRenderPath(String spriteType) //if the sprite for the given emotion cannot be found, it will try to render the generic sprite instead. If the generic sprite cannot be found, the invalid texture is allowed to proceed if(!(abstractTexture instanceof SimpleTexture)) { - ResourceLocation fallbackSpritePath = new ResourceLocation(Minestuck.MOD_ID, "textures/gui/dialogue/entity/" + spriteType + "/" + Emotion.GENERIC.getSerializedName() + ".png"); + ResourceLocation fallbackSpritePath = new ResourceLocation(Minestuck.MOD_ID, "textures/gui/dialogue/entity/" + spriteType + "/" + GENERIC_EMOTION + ".png"); if(Minecraft.getInstance().getTextureManager().getTexture(fallbackSpritePath) instanceof SimpleTexture fallbackTexture) { ensureAnimatable(fallbackTexture, fallbackSpritePath); @@ -88,22 +93,4 @@ private static void ensureAnimatable(AbstractTexture abstractTexture, ResourceLo Minecraft.getInstance().getTextureManager().register(sprite, animatableTexture); } } - - /** - * List of supported/used emotion types. Custom emotions can still be declared through datapacks - */ - public enum Emotion implements StringRepresentable - { - GENERIC, - PLEASED, - UPSET, - SCARED, - ANXIOUS; - - @Override - public String getSerializedName() - { - return name().toLowerCase(Locale.ROOT); - } - } } \ No newline at end of file