Skip to content

Commit

Permalink
1.20/fixes (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 authored May 16, 2024
1 parent 9afd332 commit f658ce7
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;

import static whocraft.tardis_refined.TardisRefined.IS_CONTROL_GROUP;
import static whocraft.tardis_refined.TardisRefined.IS_RELEASE;

public class ControlGroupCheckers {
Expand All @@ -30,7 +31,7 @@ public ControlGroupCheckers() {
}

public static void tickServer(MinecraftServer serverLevel){
if(IS_RELEASE) return;
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! :("));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class TardisRefined {

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

public static final String MODID = "tardis_refined";
public static final String NAME = "Tardis Refined";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import whocraft.tardis_refined.registry.TRDimensionTypes;
import whocraft.tardis_refined.registry.TRSoundRegistry;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -241,22 +242,10 @@ public void sync() {
}


// A map that stores information about Tardis instances, keyed by level resource key
protected static Map<ResourceKey<Level>, TardisClientData> DATA = Util.make(new Object2ObjectOpenHashMap<>(), (objectOpenHashMap) -> {
// Set the default return value for the map to be a new TardisIntReactions instance with a null level resource key
objectOpenHashMap.defaultReturnValue(new TardisClientData(null));
});
private static final List<TardisClientData> DATA = new ArrayList<>();


/**
* Registers information about a Tardis instance.
*
* @param tardisClientData The TardisIntReactions instance containing information about the Tardis.
* @param levelResourceKey The resource key of the level the Tardis is in.
*/
public static void add(TardisClientData tardisClientData, ResourceKey<Level> levelResourceKey) {
// Add the information about the Tardis to the map
DATA.put(levelResourceKey, tardisClientData);
public static void add(TardisClientData tardisClientData) {
DATA.add(tardisClientData);
}

/**
Expand All @@ -266,30 +255,24 @@ public static void add(TardisClientData tardisClientData, ResourceKey<Level> lev
* @return The TardisIntReactions instance containing information about the Tardis.
*/
public static TardisClientData getInstance(ResourceKey<Level> levelResourceKey) {
// Check if the map contains information about the Tardis
if (DATA.containsKey(levelResourceKey)) {
// If the map contains information about the Tardis, return it
return DATA.get(levelResourceKey);
for (TardisClientData data : DATA) {
if (data.getLevelKey().equals(levelResourceKey)) {
return data;
}
}

// If the map does not contain information about the Tardis, create a new TardisIntReactions instance and add it to the map
DATA.put(levelResourceKey, new TardisClientData(levelResourceKey));
return DATA.get(levelResourceKey);
TardisClientData newData = new TardisClientData(levelResourceKey);
DATA.add(newData);
return newData;
}

public static Map<ResourceKey<Level>, TardisClientData> getAllEntries() {
return DATA;
public static List<TardisClientData> getAllEntries() {
return new ArrayList<>(DATA);
}

/**
* Clears all Tardis information from the map.
*/
public static void clearAll() {
// Clear the map
DATA.clear();
}


public Vec3 fogColor(boolean isCrashing) {
if (isCrashing) {
return new Vec3(1, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ public static void tickClientData(Minecraft client) {
}
}

TardisClientData.getAllEntries().forEach((levelResourceKey, tardisClientData) -> TardisClientLogic.tickClientside(tardisClientData));
for (TardisClientData tardisClientData : TardisClientData.getAllEntries()) {
TardisClientLogic.tickClientside(tardisClientData);
}
}

private static void createWorldAmbience(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.client.ModelRegistry;
import whocraft.tardis_refined.client.model.blockentity.shell.*;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
Expand All @@ -18,7 +21,7 @@ public class ConsoleModelCollection {

ConsoleUnit toyotaConsoleModel, coralConsoleModel, copperConsoleModel, nukaConsoleModel, factoryConsoleModel, crystalConsoleModel, victorianConsoleModel, mystConsoleModel, initiativeConsoleModel, refurbishedConsoleModel;

public static Map<ResourceLocation, ConsoleUnit> CONSOLE_MODELS = new HashMap<>();
public static List<ConsoleUnit> CONSOLE_MODELS = new ArrayList<>();

public ConsoleModelCollection() {
var context = Minecraft.getInstance().getEntityModels();
Expand All @@ -38,16 +41,16 @@ public void registerModels(EntityModelSet context){
initiativeConsoleModel = new InitiativeConsoleModel(context.bakeLayer((ModelRegistry.INITIATIVE_CONSOLE)));
refurbishedConsoleModel = new RefurbishedConsoleModel(context.bakeLayer((ModelRegistry.REFURBISHED_CONSOLE)));

CONSOLE_MODELS.put(ConsoleTheme.FACTORY.getId(), factoryConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.NUKA.getId(), nukaConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.COPPER.getId(), copperConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.CORAL.getId(), coralConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.TOYOTA.getId(), toyotaConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.CRYSTAL.getId(), crystalConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.VICTORIAN.getId(), victorianConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.MYST.getId(), mystConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.INITIATIVE.getId(), initiativeConsoleModel);
CONSOLE_MODELS.put(ConsoleTheme.REFURBISHED.getId(), refurbishedConsoleModel);
CONSOLE_MODELS.add(factoryConsoleModel);
CONSOLE_MODELS.add(nukaConsoleModel);
CONSOLE_MODELS.add( copperConsoleModel);
CONSOLE_MODELS.add(coralConsoleModel);
CONSOLE_MODELS.add(toyotaConsoleModel);
CONSOLE_MODELS.add(crystalConsoleModel);
CONSOLE_MODELS.add(victorianConsoleModel);
CONSOLE_MODELS.add(mystConsoleModel);
CONSOLE_MODELS.add(initiativeConsoleModel);
CONSOLE_MODELS.add(refurbishedConsoleModel);

}

Expand All @@ -58,7 +61,13 @@ public void registerModels(EntityModelSet context){
* @return Console unit model tied with the console theme.
**/
public ConsoleUnit getConsoleModel(ResourceLocation themeId) {
return CONSOLE_MODELS.get(themeId);
for (ConsoleUnit consoleModel : CONSOLE_MODELS) {
if(consoleModel.getConsoleTheme().toString().equals(themeId.toString())){
return consoleModel;
}
}
TardisRefined.LOGGER.warn("Could not find model for {}, did you bind it?", themeId);
return null;
}

private static ConsoleModelCollection instance = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ default ModelPart findPart(HierarchicalModel hierarchicalModel, String string) {
}

ResourceLocation getDefaultTexture();
ResourceLocation getConsoleTheme();


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class CopperConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -2278,4 +2279,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return COPPER_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.COPPER.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3598,6 +3598,11 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
anim_parts.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.CORAL.getId();
}

@Override
public ResourceLocation getDefaultTexture() {
return CORAL_TEXTURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class CrystalConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -833,6 +834,11 @@ public ResourceLocation getDefaultTexture() {
return CRYSTAL_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.CRYSTAL.getId();
}

@Override
public void setupAnim(Entity entity, float f, float g, float h, float i, float j) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class FactoryConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -2293,4 +2294,9 @@ public void setupAnim(Entity entity, float f, float g, float h, float i, float j
public ResourceLocation getDefaultTexture() {
return FACTORY_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.FACTORY.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class InitiativeConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -2504,4 +2505,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return INITIATIVE_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.INITIATIVE.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import whocraft.tardis_refined.client.TardisClientData;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class MystConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -616,4 +617,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return MYST_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.MYST.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class NukaConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -525,4 +526,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return NUKA_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.NUKA.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class RefurbishedConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -1239,6 +1240,11 @@ public ResourceLocation getDefaultTexture() {
return REFURBISHED_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.REFURBISHED.getId();
}

@Override
public void setupAnim(Entity entity, float f, float g, float h, float i, float j) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

import java.util.Calendar;

Expand Down Expand Up @@ -1516,4 +1517,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return TOYOTA_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.TOYOTA.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;

public class VictorianConsoleModel extends HierarchicalModel implements ConsoleUnit {

Expand Down Expand Up @@ -2318,4 +2319,9 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
public ResourceLocation getDefaultTexture() {
return VICTORIAN_TEXTURE;
}

@Override
public ResourceLocation getConsoleTheme() {
return ConsoleTheme.VICTORIAN.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public void render(GlobalConsoleBlockEntity blockEntity, float partialTick, Pose
ResourceLocation theme = blockEntity.theme();

ConsoleUnit consoleModel = ConsoleModelCollection.getInstance().getConsoleModel(theme);
consoleModel.renderConsole(blockEntity, Objects.requireNonNull(blockEntity.getLevel()), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getTexture(blockEntity))), packedLight, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);
consoleModel.renderConsole(blockEntity, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getTexture(blockEntity))), packedLight, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);

if (blockEntity != null && blockEntity.getBlockState().getValue(GlobalConsoleBlock.POWERED)) {
if(blockEntity.pattern() != null && blockEntity.pattern().patternTexture().emissive()) {
consoleModel.renderConsole(blockEntity, Objects.requireNonNull(blockEntity.getLevel()), poseStack, bufferSource.getBuffer(RenderType.entityTranslucentEmissive(consoleModel.getTexture(blockEntity, true))), 15728640, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);
consoleModel.renderConsole(blockEntity, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucentEmissive(consoleModel.getTexture(blockEntity, true))), 15728640, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public void render(ConsoleConfigurationBlockEntity blockEntity, float partialTic
ResourceLocation theme = blockEntity.theme();

ConsoleUnit consoleModel = ConsoleModelCollection.getInstance().getConsoleModel(theme);
consoleModel.renderConsole(null, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getDefaultTexture())), packedLight, OverlayTexture.NO_OVERLAY, 0.635f, 0.392f, 0.878f, 0.5f);
if (consoleModel != null) {
consoleModel.renderConsole(null, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getDefaultTexture())), packedLight, OverlayTexture.NO_OVERLAY, 0.635f, 0.392f, 0.878f, 0.5f);
}
}

poseStack.popPose();
Expand Down
Loading

0 comments on commit f658ce7

Please sign in to comment.