-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ChatCoordinatesScreen with the check feature
- Loading branch information
Showing
4 changed files
with
64 additions
and
11 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
7 changes: 2 additions & 5 deletions
7
src/client/java/net/The2019/NewBase/features/ChatCoordinates.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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
package net.The2019.NewBase.features; | ||
|
||
import net.The2019.NewBase.screen.ChatCoordinatesScreen; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class ChatCoordinates { | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
|
||
public static void sendCoordinates(){ | ||
if (mc.player != null) { | ||
BlockPos playerPos = mc.player.getBlockPos(); | ||
mc.player.networkHandler.sendChatMessage(String.format("X: %s Y: %s Z: %s", playerPos.getX(), playerPos.getY(), playerPos.getZ())); | ||
} | ||
mc.setScreen(new ChatCoordinatesScreen(mc.currentScreen, mc.options)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/client/java/net/The2019/NewBase/screen/ChatCoordinatesScreen.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,43 @@ | ||
package net.The2019.NewBase.screen; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.client.gui.widget.TextWidget; | ||
import net.minecraft.client.option.GameOptions; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ChatCoordinatesScreen extends Screen { | ||
private final Screen parent; | ||
private final GameOptions settings; | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
|
||
public ChatCoordinatesScreen(Screen parent, GameOptions options) { | ||
super(Text.of("Chat Coordinates Screen")); | ||
this.parent = parent; | ||
this.settings = options; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
ButtonWidget yesButton = new ButtonWidget.Builder(Text.literal("§aYes"), button -> { | ||
if (mc.player != null) { | ||
BlockPos playerPos = mc.player.getBlockPos(); | ||
mc.player.networkHandler.sendChatMessage(String.format("X: %s Y: %s Z: %s", playerPos.getX(), playerPos.getY(), playerPos.getZ())); | ||
mc.setScreen(null); | ||
} | ||
}).dimensions(this.width / 2 - 90, this.height / 2, 80, 20).build(); | ||
|
||
ButtonWidget noButton = new ButtonWidget.Builder(Text.literal("§4No"), button -> { | ||
mc.setScreen(null); | ||
}).dimensions(this.width / 2, this.height / 2, 80, 20).build(); | ||
|
||
this.addDrawable(new TextWidget(this.width / 2 - 250, this.height / 2 - 30, 500, 20, Text.of("Press §aYes §fto send Coordinates in the chat or §4No §fto return back to the game."), textRenderer)); | ||
this.addDrawableChild(yesButton); | ||
this.addDrawableChild(noButton); | ||
} | ||
} | ||
|
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