-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
207 changed files
with
74,337 additions
and
1,728 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +0,0 @@ | ||
package whocraft.tardis_refined; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParser; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.MinecraftServer; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static whocraft.tardis_refined.TardisRefined.IS_CONTROL_GROUP; | ||
|
||
public class ControlGroupCheckers { | ||
|
||
public static final ControlGroupCheckers INSTANCE = new ControlGroupCheckers(); | ||
private static final String API_URL = "https://mc.craig.software/api/skin/beta_players"; | ||
private final List<String> uuidList = new ArrayList<>(); | ||
|
||
public ControlGroupCheckers() { | ||
if(IS_CONTROL_GROUP) { | ||
fetchUUIDsFromAPI(); | ||
} | ||
} | ||
|
||
public static void tickServer(MinecraftServer serverLevel) { | ||
if (!IS_CONTROL_GROUP) return; | ||
serverLevel.getPlayerList().getPlayers().iterator().forEachRemaining(serverPlayer -> { | ||
if (!ControlGroupCheckers.INSTANCE.isUUIDInList(serverPlayer.getStringUUID())) { | ||
serverPlayer.connection.disconnect(Component.literal("Womp Womp! You're not on the list! :(")); | ||
} | ||
}); | ||
} | ||
|
||
|
||
public void fetchUUIDsFromAPI() { | ||
try { | ||
URL url = new URL(API_URL); | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
connection.setRequestMethod("GET"); | ||
|
||
int responseCode = connection.getResponseCode(); | ||
if (responseCode == HttpURLConnection.HTTP_OK) { | ||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | ||
String inputLine; | ||
StringBuilder response = new StringBuilder(); | ||
|
||
while ((inputLine = in.readLine()) != null) { | ||
response.append(inputLine); | ||
} | ||
in.close(); | ||
|
||
// Parse JSON response and extract UUIDs | ||
parseJSON(response.toString()); | ||
} else { | ||
System.out.println("Failed to fetch UUIDs from API. Response code: " + responseCode); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private void parseJSON(String jsonResponse) { | ||
JsonArray jsonArray = JsonParser.parseString(jsonResponse).getAsJsonArray(); | ||
for (JsonElement element : jsonArray) { | ||
String uuid = element.getAsJsonObject().get("uuid").getAsString(); | ||
uuidList.add(uuid); | ||
} | ||
} | ||
|
||
public boolean isUUIDInList(String uuid) { | ||
return uuidList.contains(uuid); | ||
} | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +0,0 @@ | ||
|
||
package whocraft.tardis_refined.client; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.Tesselator; | ||
import com.mojang.math.Transformation; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Font; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.world.entity.player.Player; | ||
import whocraft.tardis_refined.common.GravityUtil; | ||
import whocraft.tardis_refined.constants.ModMessages; | ||
|
||
public class GravityOverlay { | ||
|
||
private static boolean isInShaft = false; | ||
|
||
private static void checkOverlay(Player player){ | ||
isInShaft = GravityUtil.isInGravityShaft(player); | ||
} | ||
|
||
public static void renderOverlay(PoseStack poseStack) { | ||
Minecraft mc = Minecraft.getInstance(); | ||
Font fontRenderer = mc.font; | ||
LocalPlayer player = mc.player; | ||
|
||
if(player.tickCount % 100 == 0){ | ||
checkOverlay(player); | ||
} | ||
|
||
if (isInShaft && !mc.options.renderDebug) { | ||
poseStack.pushPose(); | ||
poseStack.scale(1.2f, 1.2f, 1.2f); | ||
|
||
|
||
int x = 5; | ||
int y = 5; | ||
|
||
MutableComponent ascendKey = Component.translatable(mc.options.keyJump.getDefaultKey().getName()); | ||
MutableComponent descendKey = Component.translatable(mc.options.keyShift.getDefaultKey().getName()); | ||
|
||
MultiBufferSource.BufferSource renderImpl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); | ||
fontRenderer.drawInBatch(Component.translatable(ModMessages.ASCEND_KEY, ascendKey).getString(), x, y, ChatFormatting.WHITE.getColor(), true, Transformation.identity().getMatrix(), renderImpl, Font.DisplayMode.NORMAL, 0, 15728880); | ||
fontRenderer.drawInBatch(Component.translatable(Component.translatable(ModMessages.DESCEND_KEY, descendKey).getString()), x, y + fontRenderer.lineHeight, ChatFormatting.WHITE.getColor(), true, Transformation.identity().getMatrix(), renderImpl, Font.DisplayMode.NORMAL, 0, 15728880); | ||
renderImpl.endBatch(); | ||
|
||
poseStack.popPose(); | ||
} | ||
} | ||
|
||
} | ||
Oops, something went wrong.