-
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.
Eye of Harmony and Fuel Refueling (#219)
Co-authored-by: Craig <[email protected]>
- Loading branch information
1 parent
5f444ad
commit 0f7d782
Showing
141 changed files
with
2,482 additions
and
1,058 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
common/src/main/java/whocraft/tardis_refined/ControlGroupCheckers.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,79 @@ | ||
package whocraft.tardis_refined; | ||
|
||
import com.google.gson.Gson; | ||
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 net.minecraft.server.level.ServerLevel; | ||
|
||
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_RELEASE; | ||
|
||
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 List<String> uuidList; | ||
|
||
public ControlGroupCheckers() { | ||
this.uuidList = new ArrayList<>(); | ||
fetchUUIDsFromAPI(); | ||
} | ||
|
||
public static void tickServer(MinecraftServer serverLevel){ | ||
if(IS_RELEASE) 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
42 changes: 42 additions & 0 deletions
42
.../java/whocraft/tardis_refined/client/model/blockentity/device/ArtronPillarBlockModel.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 whocraft.tardis_refined.client.model.blockentity.device;// Made with Blockbench 4.9.4 | ||
// Exported for Minecraft version 1.17 or later with Mojang mappings | ||
// Paste this class into your mod and generate all required imports | ||
|
||
|
||
import net.minecraft.client.model.HierarchicalModel; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
import net.minecraft.world.entity.Entity; | ||
|
||
public class ArtronPillarBlockModel extends HierarchicalModel { | ||
|
||
private final ModelPart root; | ||
private final ModelPart bb_main; | ||
|
||
public ArtronPillarBlockModel(ModelPart root) { | ||
this.root = root; | ||
this.bb_main = root.getChild("bb_main"); | ||
} | ||
|
||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
|
||
PartDefinition bb_main = partdefinition.addOrReplaceChild("bb_main", CubeListBuilder.create().texOffs(24, 29).addBox(-4.0F, -16.0F, -4.0F, 8.0F, 16.0F, 8.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 29).addBox(-3.0F, -52.0F, -3.0F, 6.0F, 36.0F, 6.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 0).addBox(-6.0F, -69.0F, -6.0F, 12.0F, 17.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); | ||
|
||
return LayerDefinition.create(meshdefinition, 128, 128); | ||
} | ||
|
||
@Override | ||
public ModelPart root() { | ||
return this.root; | ||
} | ||
|
||
@Override | ||
public void setupAnim(Entity entity, float f, float g, float h, float i, float j) { | ||
|
||
} | ||
} |
Oops, something went wrong.