-
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.
Implemented new Hud rendering system and added permission levels
- Loading branch information
Showing
8 changed files
with
153 additions
and
17 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
28 changes: 28 additions & 0 deletions
28
src/client/java/net/The2019/NewBase/features/AutoCrystal.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,28 @@ | ||
package net.The2019.NewBase.features; | ||
|
||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.decoration.EndCrystalEntity; | ||
|
||
import static net.The2019.NewBase.utils.PermsionLevel.isPlayerAllowed; | ||
|
||
public class AutoCrystal { | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
|
||
public static void autoCrystal(){ | ||
if(isPlayerAllowed){ | ||
ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
if (mc.world != null) { | ||
for(Entity entity : mc.world.getEntities()){ | ||
if(entity instanceof EndCrystalEntity){ | ||
if (mc.interactionManager != null) { | ||
mc.interactionManager.attackEntity(mc.player, entity); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
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,9 @@ | ||
package net.The2019.NewBase.features; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
|
||
public class FpsDisplay { | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
|
||
public static String fps = mc.fpsDebugString.toString(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
package net.The2019.NewBase.render; | ||
|
||
import net.The2019.NewBase.features.CoordinatesDisplay; | ||
import net.The2019.NewBase.features.BiomDisplay; | ||
import net.The2019.NewBase.features.CoordinatesDisplay; | ||
import net.The2019.NewBase.features.FpsDisplay; | ||
import net.The2019.NewBase.utils.DisplayElements; | ||
import net.The2019.NewBase.utils.DisplayTextSupplier; | ||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.font.TextRenderer; | ||
|
||
import java.awt.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class HudRender { | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
private static final List<DisplayElements> displayElements = new ArrayList<>(); | ||
|
||
public static void hudRendering() { | ||
// Add your display elements to the list | ||
displayElements.add(new DisplayElements("Coordinates", Color.GREEN.getRGB(), () -> "X: " + CoordinatesDisplay.x + " Y: " + CoordinatesDisplay.y + " Z: " + CoordinatesDisplay.z)); | ||
displayElements.add(new DisplayElements("Biom", Color.GREEN.getRGB(), () -> "Biom: " + BiomDisplay.biom)); | ||
displayElements.add(new DisplayElements("Fps", Color.GREEN.getRGB(), () -> "FPS: " + FpsDisplay.fps)); | ||
|
||
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> { | ||
TextRenderer renderer = mc.textRenderer; | ||
int yOffset = 10; | ||
|
||
public static void hudRendering(){ | ||
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> { | ||
TextRenderer renderer = mc.textRenderer; | ||
drawContext.drawText(renderer,"X: " + CoordinatesDisplay.x + " " + "Y: " + CoordinatesDisplay.y + " " + "Z: " + CoordinatesDisplay.z, 10, 10, Color.GREEN.getRGB(), false); | ||
drawContext.drawText(renderer, "Biom: " + BiomDisplay.biom, 10, 20, Color.GREEN.getRGB(), false); | ||
}); | ||
// Render each active display element | ||
for (DisplayElements element : displayElements) { | ||
if (element.isActive()) { | ||
drawContext.drawText(renderer, element.getText(), 10, yOffset, element.getColor(), false); | ||
yOffset += 10; // Adjust the Y position for the next element | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/client/java/net/The2019/NewBase/utils/DisplayElements.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,36 @@ | ||
package net.The2019.NewBase.utils; | ||
|
||
public class DisplayElements { | ||
private final String name; | ||
private final int color; | ||
private final DisplayTextSupplier textSupplier; | ||
private boolean active; | ||
|
||
public DisplayElements(String name, int color, DisplayTextSupplier textSupplier) { | ||
this.name = name; | ||
this.color = color; | ||
this.textSupplier = textSupplier; | ||
this.active = true; // Elements are active by default | ||
} | ||
|
||
public String getText() { | ||
return textSupplier.getDisplayText(); | ||
} | ||
|
||
public boolean isActive() { | ||
return active; | ||
} | ||
|
||
public void setActive(boolean active) { | ||
this.active = active; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getColor() { | ||
return color; | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
src/client/java/net/The2019/NewBase/utils/DisplayTextSupplier.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,6 @@ | ||
package net.The2019.NewBase.utils; | ||
|
||
@FunctionalInterface | ||
public interface DisplayTextSupplier { | ||
String getDisplayText(); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/client/java/net/The2019/NewBase/utils/PermsionLevel.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,29 @@ | ||
package net.The2019.NewBase.utils; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class PermsionLevel { | ||
private static final ArrayList<String> allowedPlayers = new ArrayList<>(); | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
public static Boolean isPlayerAllowed = false; | ||
|
||
public static void init(){ | ||
addPlayers("The2019"); | ||
addPlayers("TheChrisgamer18"); | ||
} | ||
|
||
public static void isPlayerAllowed(){ | ||
if (mc.player != null) { | ||
String playername = mc.player.getName().toString(); | ||
if(allowedPlayers.contains(playername)){ | ||
isPlayerAllowed = true; | ||
} | ||
} | ||
} | ||
|
||
private static void addPlayers(String players){ | ||
allowedPlayers.add(players); | ||
} | ||
} |