Skip to content

Commit ee42101

Browse files
committed
Add gravity toggle to models
1 parent 8fb0da8 commit ee42101

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/main/java/ca/atlasengine/gui/windows/ModelModifyGUI.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public AnimationSelect() {
2525
}
2626
}
2727

28-
public ModelModifyGUI(List<String> animations, UUID uuid, String modelName, int customModelData, boolean hideOnLoad) {
28+
public ModelModifyGUI(List<String> animations, UUID uuid, String modelName, int customModelData, boolean hideOnLoad, boolean gravity) {
2929
WGridPanel root = new WGridPanel();
3030
setRootPanel(root);
3131

@@ -65,6 +65,14 @@ public ModelModifyGUI(List<String> animations, UUID uuid, String modelName, int
6565
hideOnLoadButton.setToggle(hideOnLoad);
6666
root.add(hideOnLoadButton, 2, 4, 5, 1);
6767

68+
WToggleButton gravityButton = new WToggleButton(Text.of("Has Gravity"));
69+
gravityButton.setOnToggle((b) -> {
70+
ModelManager.setGravity(uuid, b);
71+
});
72+
73+
gravityButton.setToggle(gravity);
74+
root.add(gravityButton, 2, 5, 5, 1);
75+
6876
var moveButton = new WButton(Text.of("Move Model"));
6977
moveButton.setOnClick(() -> {
7078
ModelManager.moveModel(uuid);
@@ -73,14 +81,6 @@ public ModelModifyGUI(List<String> animations, UUID uuid, String modelName, int
7381

7482
root.add(moveButton, 1, 2, 5, 1);
7583

76-
var closeButton = new WButton(Text.of("Delete Model"));
77-
closeButton.setOnClick(() -> {
78-
ModelManager.deleteModel(uuid);
79-
MinecraftClient.getInstance().setScreen(null);
80-
});
81-
82-
root.add(closeButton, 1, root.getHeight() / 16 - 4, 5, 1);
83-
8484
var stopAnimations = new WButton(Text.of("Stop Animation"));
8585
stopAnimations.setOnClick(() -> {
8686
ModelManager.setAnimation(uuid, "");

src/main/java/ca/atlasengine/models/ModelLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ public static void receive(PacketByteBuf packetByteBuf) {
4848
String name = packetByteBuf.readString();
4949
int customModelData = packetByteBuf.readInt();
5050
boolean hideOnLoad = packetByteBuf.readBoolean();
51+
boolean gravity = packetByteBuf.readBoolean();
5152

5253
int count = packetByteBuf.readInt();
5354
List<String> animations = new ArrayList<>();
5455
for (int i = 0; i < count; i++) {
5556
animations.add(packetByteBuf.readString());
5657
}
5758

58-
providedScreen = new GUIScreen(new ModelModifyGUI(animations, uuid, name, customModelData, hideOnLoad));
59+
providedScreen = new GUIScreen(new ModelModifyGUI(animations, uuid, name, customModelData, gravity, hideOnLoad));
5960
}
6061
}
6162
}

src/main/java/ca/atlasengine/models/ModelManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,13 @@ public static void setHideOnLoad(UUID uuid, Boolean b) {
8787

8888
ClientPlayNetworking.send(animationIdentifier, buf);
8989
}
90+
91+
public static void setGravity(UUID uuid, Boolean b) {
92+
PacketByteBuf buf = PacketByteBufs.create();
93+
buf.writeByte(7);
94+
buf.writeUuid(uuid);
95+
buf.writeBoolean(b);
96+
97+
ClientPlayNetworking.send(animationIdentifier, buf);
98+
}
9099
}

0 commit comments

Comments
 (0)