-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing to mirror pose, mirror legs, mirror arms, swap main hand with head and swap main and off hand
- Loading branch information
Showing
14 changed files
with
270 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
common/src/main/java/com/mrbysco/armorposer/client/gui/widgets/PoseImageButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mrbysco.armorposer.client.gui.widgets; | ||
|
||
import com.mrbysco.armorposer.Reference; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.components.Button; | ||
import net.minecraft.client.gui.components.Tooltip; | ||
import net.minecraft.client.gui.screens.inventory.BookViewScreen; | ||
import net.minecraft.network.chat.CommonComponents; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class PoseImageButton extends Button { | ||
private static final ResourceLocation BUTTON_LOCATION = new ResourceLocation(Reference.MOD_ID, "textures/gui/poser_buttons.png"); | ||
private final int yOffset; | ||
|
||
public PoseImageButton(int x, int y, Button.OnPress onPress, int buttonID) { | ||
super(x, y, 20, 20, CommonComponents.EMPTY, onPress, DEFAULT_NARRATION); | ||
this.yOffset = buttonID == 0 ? 0 : buttonID * 20; | ||
} | ||
|
||
public PoseImageButton(int x, int y, Button.OnPress onPress, int buttonID, Tooltip tooltip) { | ||
this(x, y, onPress, buttonID); | ||
this.setTooltip(tooltip); | ||
} | ||
|
||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { | ||
int i = 0; | ||
if (this.isHovered()) { | ||
i += 20; | ||
} | ||
|
||
guiGraphics.blit(PoseImageButton.BUTTON_LOCATION, this.getX(), this.getY(), i, yOffset, 20, 20, 64, 128); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
common/src/main/java/com/mrbysco/armorposer/data/SwapData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.mrbysco.armorposer.data; | ||
|
||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.decoration.ArmorStand; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.UUID; | ||
|
||
public record SwapData(UUID entityUUID, Action action) { | ||
public void encode(FriendlyByteBuf buf) { | ||
buf.writeUUID(entityUUID); | ||
buf.writeEnum(action); | ||
} | ||
|
||
public static SwapData decode(final FriendlyByteBuf packetBuffer) { | ||
return new SwapData(packetBuffer.readUUID(), packetBuffer.readEnum(Action.class)); | ||
} | ||
|
||
public void handleData(ArmorStand armorStand) { | ||
switch (action) { | ||
case SWAP_HANDS: | ||
ItemStack offStack = armorStand.getItemInHand(InteractionHand.OFF_HAND); | ||
armorStand.setItemInHand(InteractionHand.OFF_HAND, armorStand.getItemInHand(InteractionHand.MAIN_HAND)); | ||
armorStand.setItemInHand(InteractionHand.MAIN_HAND, offStack); | ||
return; | ||
case SWAP_WITH_HEAD: | ||
ItemStack headStack = armorStand.getItemBySlot(EquipmentSlot.HEAD); | ||
armorStand.setItemSlot(EquipmentSlot.HEAD, armorStand.getItemBySlot(EquipmentSlot.MAINHAND)); | ||
armorStand.setItemSlot(EquipmentSlot.MAINHAND, headStack); | ||
return; | ||
default: | ||
throw new IllegalArgumentException("Invalid Pose action"); | ||
} | ||
} | ||
|
||
public static enum Action { | ||
SWAP_WITH_HEAD, | ||
SWAP_HANDS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.02 KB
common/src/main/resources/assets/armorposer/textures/gui/poser_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.