Skip to content

Commit

Permalink
Eye of Harmony and Fuel Refueling (#219)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig <[email protected]>
  • Loading branch information
CommandrMoose and Jeryn99 authored Apr 14, 2024
1 parent 5f444ad commit 0f7d782
Show file tree
Hide file tree
Showing 141 changed files with 2,482 additions and 1,058 deletions.
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);
}
}
28 changes: 16 additions & 12 deletions common/src/main/java/whocraft/tardis_refined/TardisRefined.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.logging.LogUtils;
import net.minecraft.SharedConstants;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
Expand All @@ -20,13 +21,16 @@
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
import whocraft.tardis_refined.common.world.ChunkGenerators;
import whocraft.tardis_refined.common.world.Features;
import whocraft.tardis_refined.registry.ARSStructurePieceRegistry;
import whocraft.tardis_refined.registry.TRARSStructurePieceRegistry;
import whocraft.tardis_refined.patterns.ConsolePatterns;
import whocraft.tardis_refined.patterns.ShellPatterns;
import whocraft.tardis_refined.registry.*;

public class TardisRefined {

public static boolean IS_CONTROL_GROUP = true;
public static boolean IS_RELEASE = !IS_CONTROL_GROUP || !SharedConstants.IS_RUNNING_IN_IDE;

public static final String MODID = "tardis_refined";
public static final String NAME = "Tardis Refined";
public static final String PLATFORM_ERROR = "Something has gone critically wrong with platform definitions. Please contact the mod author.";
Expand All @@ -40,22 +44,22 @@ public class TardisRefined {

public static void init() {

ItemRegistry.TABS.register();
BlockRegistry.BLOCKS.register();
ItemRegistry.ITEMS.register();
EntityRegistry.ENTITY_TYPES.register();
SoundRegistry.SOUNDS.register();
BlockEntityRegistry.BLOCK_ENTITY_TYPES.register();
DimensionTypes.register();
TRItemRegistry.TABS.register();
TRBlockRegistry.BLOCKS.register();
TRItemRegistry.ITEMS.register();
TREntityRegistry.ENTITY_TYPES.register();
TRSoundRegistry.SOUNDS.register();
TRBlockEntityRegistry.BLOCK_ENTITY_TYPES.register();
TRDimensionTypes.register();
ChunkGenerators.CHUNK_GENERATORS.register();
Features.FEATURES.register();
TRParticles.TYPES.register();
Upgrades.UPGRADE_DEFERRED_REGISTRY.register();
ConsoleTheme.CONSOLE_THEMES.register();
ShellTheme.SHELL_THEMES.register();
ControlRegistry.CONTROLS.register();
ArgumentTypeRegistry.COMMAND_ARGUMENT_TYPES.register();
TagKeys.init();
TRControlRegistry.CONTROLS.register();
TRArgumentTypeRegistry.COMMAND_ARGUMENT_TYPES.register();
TRTagKeys.init();
TardisNetwork.init();
TardisDesktops.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncDesktopsMessage::new);
ConsolePatterns.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncConsolePatternsMessage::new);
Expand All @@ -68,7 +72,7 @@ public static void init() {
ShellPatterns.registerDefaultPatterns();
TardisHums.registerDefaultHums();

ARSStructurePieceRegistry.register();
TRARSStructurePieceRegistry.register();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.client.model.blockentity.device.ArtronPillarBlockModel;
import whocraft.tardis_refined.client.model.blockentity.console.*;
import whocraft.tardis_refined.client.model.blockentity.door.interior.*;
import whocraft.tardis_refined.client.model.blockentity.life.ArsEggModel;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class ModelRegistry {
public static ModelLayerLocation HIEROGLYPH_SHELL;
public static ModelLayerLocation CASTLE_SHELL;
public static ModelLayerLocation PATHFINDER_SHELL;
public static ModelLayerLocation HALF_BAKED_SHELL;


public static ModelLayerLocation ROOT_SHELL_DOOR;
Expand All @@ -75,10 +77,12 @@ public class ModelRegistry {
public static ModelLayerLocation HIEROGLYPH_DOOR;
public static ModelLayerLocation CASTLE_DOOR;
public static ModelLayerLocation PATHFINDER_DOOR;
public static ModelLayerLocation HALF_BAKED_DOOR;


public static ModelLayerLocation ARS_EGG;
public static ModelLayerLocation BULK_HEAD_DOOR;
public static ModelLayerLocation ARTRON_PILLAR;


public static void init() {
Expand Down Expand Up @@ -118,6 +122,7 @@ public static void init() {
HIEROGLYPH_SHELL = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "hieroglyph_shell"), "hieroglyph_shell"), HieroglyphModel::createBodyLayer);
CASTLE_SHELL = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "castle_shell"), "castle_shell"), CastleShellModel::createBodyLayer);
PATHFINDER_SHELL = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "pathfinder_shell"), "pathfinder_shell"), PathfinderShellModel::createBodyLayer);
HALF_BAKED_SHELL = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "half_baked_shell"), "half_baked_shell"), HalfBakedShellModel::createBodyLayer);


ROOT_SHELL_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "root_shell_door"), "root_shell_door"), RootShellDoorModel::createBodyLayer);
Expand All @@ -139,9 +144,11 @@ public static void init() {
HIEROGLYPH_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "hieroglyph_door"), "hieroglyph_door"), HieroglyphShellDoor::createBodyLayer);
CASTLE_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "castle_door"), "castle_door"), CastleShellDoorModel::createBodyLayer);
PATHFINDER_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "pathfinder_door"), "pathfinder_door"), PathfinderShellModel::createBodyLayer);
HALF_BAKED_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "half_baked_door"), "half_baked_door"), HalfBakedDoorModel::createBodyLayer);

ARS_EGG = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "ars_egg"), "ars_egg"), ArsEggModel::createBodyLayer);
BULK_HEAD_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "bulk_head_door"), "bulk_head_door"), BulkHeadDoorModel::createBodyLayer);
ARTRON_PILLAR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "artron_pillar"), "artron_pillar"), ArtronPillarBlockModel::createBodyLayer);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import whocraft.tardis_refined.client.sounds.LoopingSound;
import whocraft.tardis_refined.client.sounds.QuickSimpleSound;
import whocraft.tardis_refined.common.GravityUtil;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.hum.HumEntry;
import whocraft.tardis_refined.common.hum.TardisHums;
import whocraft.tardis_refined.common.network.messages.sync.SyncTardisClientDataMessage;
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
import whocraft.tardis_refined.constants.NbtConstants;
import whocraft.tardis_refined.patterns.ShellPatterns;
import whocraft.tardis_refined.registry.DimensionTypes;
import whocraft.tardis_refined.registry.SoundRegistry;
import whocraft.tardis_refined.registry.TRDimensionTypes;
import whocraft.tardis_refined.registry.TRSoundRegistry;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -72,15 +73,18 @@ public ResourceKey<Level> getLevelKey() {
private double fuel = 0;
private double maximumFuel = 0;

private int tardisState = 0;


//Not saved to disk, no real reason to be
private int nextAmbientNoiseCall = 40;

// Independent of the hums logic
private int nextVoiceAmbientCall = 12000;
private QuickSimpleSound voiceQuickSound = new QuickSimpleSound(SoundRegistry.INTERIOR_VOICE.get(), SoundSource.AMBIENT);
private QuickSimpleSound voiceQuickSound = new QuickSimpleSound(TRSoundRegistry.INTERIOR_VOICE.get(), SoundSource.AMBIENT);


private ResourceLocation shellTheme = ShellTheme.FACTORY.getId();
private ResourceLocation shellTheme = ShellTheme.HALF_BAKED.getId();
private ResourceLocation shellPattern = ShellPatterns.DEFAULT.id();

private HumEntry humEntry = TardisHums.getDefaultHum();
Expand Down Expand Up @@ -172,6 +176,7 @@ public void setMaximumFuel(double fuel) {
this.maximumFuel = fuel;
}


/**
* Higher means more fog, lower means less fog
* @return 0 -> 1 float based off fog tick delta
Expand Down Expand Up @@ -270,14 +275,13 @@ public void tickClientside() {
}


if (Minecraft.getInstance().player.level().dimensionTypeId() == DimensionTypes.TARDIS) {
if (Minecraft.getInstance().player.level().dimensionTypeId() == TRDimensionTypes.TARDIS) {

ClientLevel tardisLevel = Minecraft.getInstance().level;
boolean isThisTardis = levelKey == tardisLevel.dimension();

createWorldAmbience(Minecraft.getInstance().player);


if (LoopingSound.ARS_HUMMING == null) {
LoopingSound.setupSounds();
}
Expand All @@ -300,9 +304,11 @@ public void tickClientside() {
}

if (isThisTardis && tardisLevel.getGameTime() % nextAmbientNoiseCall == 0) {


nextAmbientNoiseCall = tardisLevel.random.nextInt(400, 2400);
List<ResourceLocation> ambientSounds = humEntry.getAmbientSounds();
if (!ambientSounds.isEmpty()) {
if (ambientSounds != null && !ambientSounds.isEmpty()) {
RandomSource randomSource = tardisLevel.random;

ResourceLocation randomSoundLocation = ambientSounds.get(randomSource.nextInt(ambientSounds.size()));
Expand Down Expand Up @@ -346,7 +352,11 @@ public void tickClientside() {
}

if (isThisTardis) {
tickFog(fuel != 0);
tickFog( tardisState < TardisLevelOperator.STATE_EYE_OF_HARMONY || fuel != 0);
}

if (isThisTardis && tardisState == TardisLevelOperator.STATE_EYE_OF_HARMONY) {
tardisLevel.addParticle(ParticleTypes.CLOUD, (double)1013 + 0.5 - 2 + tardisLevel.random.nextInt(4), 71, (double)55 + 0.5- 2 + tardisLevel.random.nextInt(4),0, 0.1 + tardisLevel.random.nextFloat() / 2 ,0);
}
}

Expand Down Expand Up @@ -506,4 +516,12 @@ public boolean isHandbrakeEngaged() {
public void setHandbrakeEngaged(boolean handbrakeEngaged) {
isHandbrakeEngaged = handbrakeEngaged;
}

public int getTardisState() {
return tardisState;
}

public void setTardisState(int tardisState) {
this.tardisState = tardisState;
}
}
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) {

}
}
Loading

0 comments on commit 0f7d782

Please sign in to comment.