getQueuedTeleports() {
- return queuedTeleports;
- }
-
/**
* This is to be called from the world tick event, if the world being ticked
* is a ServerWorld and if the tick phase is the end of the world tick.
*
* Does *not* create dynamic worlds that don't already exist,
* So dynamic worlds should be created by the thing that schedules the tick, if possible
- *
*/
public static void tick() {
TardisTeleportData eventData = TardisTeleportData.INSTANCE;
@@ -59,8 +54,7 @@ public static void tick() {
if (TRTeleporter.fullTeleport(entity, targetWorld, entry.getX(), entry.getY(), entry.getZ(), entry.getyRot(), entry.getxRot(), teleportedEntities)) {
teleportedEntities.add(entity);
entry.setSuccessfulTeleport(true);
- }
- else {
+ } else {
entry.setSuccessfulTeleport(false);
}
}
@@ -77,7 +71,7 @@ public static void tick() {
}
public static void scheduleEntityTeleport(Entity entity, ResourceKey destination, double x, double y, double z, float yRot, float xRot) {
- if(entity != null && !entity.level().isClientSide() && !isEntityQueuedToTeleportAlready(entity)) {
+ if (entity != null && !entity.level().isClientSide() && !isEntityQueuedToTeleportAlready(entity)) {
queuedTeleports.add(new TeleportEntry(entity, destination, x, y, z, yRot, xRot));
}
@@ -87,7 +81,11 @@ public static boolean isEntityQueuedToTeleportAlready(Entity entity) {
return queuedTeleports.stream().anyMatch(entry -> entry.getEntity().equals(entity));
}
- private static final class TeleportEntry{
+ public List getQueuedTeleports() {
+ return queuedTeleports;
+ }
+
+ private static final class TeleportEntry {
private final Entity entity;
private final ResourceKey destination;
diff --git a/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java b/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java
index 5f94b42d7..df721e05f 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java
@@ -46,34 +46,39 @@
public class ControlEntity extends Entity {
- /** The total amount of control alignment health points before a control will start causing the Tardis to crash.
- *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used. */
+ /**
+ * Flag to determine if this Control can continue to become more mis-aligned and thus lose "health".
+ *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used.
+ *
True - if able to keep being mis-aligned, False if cannot be further mis-aligned
+ */
+ private static final EntityDataAccessor TICKING_DOWN = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
+ /**
+ * Flag to determine if this Control is far too mis-aligned and is considered "dead".
+ *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used.
+ */
+ private static final EntityDataAccessor IS_DEAD = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
+ /**
+ * Attribute to determine how far this Control is mis-aligned.
+ *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used.
+ */
+ private static final EntityDataAccessor CONTROL_HEALTH = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.INT);
+ private static final EntityDataAccessor SHOW_PARTICLE = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
+ private static final EntityDataAccessor SIZE_WIDTH = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.FLOAT);
+ private static final EntityDataAccessor SIZE_HEIGHT = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.FLOAT);
+ /**
+ * The total amount of control alignment health points before a control will start causing the Tardis to crash.
+ *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used.
+ */
private int totalControlHealth = 10;
-
private ControlSpecification controlSpecification;
private ConsoleTheme consoleTheme;
private BlockPos consoleBlockPos;
private FlightDanceManager flightDanceManager;
private Vector3f offset;
-
public ControlEntity(EntityType> entityTypeIn, Level level) {
super(entityTypeIn, level);
}
- /** Flag to determine if this Control can continue to become more mis-aligned and thus lose "health".
- *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used.
- *
True - if able to keep being mis-aligned, False if cannot be further mis-aligned*/
- private static final EntityDataAccessor TICKING_DOWN = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
- /** Flag to determine if this Control is far too mis-aligned and is considered "dead".
- *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used. */
- private static final EntityDataAccessor IS_DEAD = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
- /** Attribute to determine how far this Control is mis-aligned.
- *
This name comes from a time when the terminology wasn't finalised, and a more traditional "health" system was being used. */
- private static final EntityDataAccessor CONTROL_HEALTH = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.INT);
- private static final EntityDataAccessor SHOW_PARTICLE = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.BOOLEAN);
- private static final EntityDataAccessor SIZE_WIDTH = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.FLOAT);
- private static final EntityDataAccessor SIZE_HEIGHT = SynchedEntityData.defineId(ControlEntity.class, EntityDataSerializers.FLOAT);
-
public ControlEntity(Level level) {
super(TREntityRegistry.CONTROL_ENTITY.get(), level);
}
@@ -143,7 +148,7 @@ public Component getName() {
TardisClientData tardisClientData = TardisClientData.getInstance(level().dimension());
- if(tardisClientData.isInRecovery()){
+ if (tardisClientData.isInRecovery()) {
int cooldownTicks = tardisClientData.getRecoveryTicks();
int maxCooldownTicks = 12000; // 10 minutes in ticks
int percentage = (int) ((cooldownTicks / (float) maxCooldownTicks) * 100);
@@ -158,7 +163,9 @@ public Component getName() {
}
- /** Tell the Tardis that the control is currently continuing to be misaligned
+ /**
+ * Tell the Tardis that the control is currently continuing to be misaligned
+ *
* @param manager
* @return true if can continue to become more misaligned, false if already too misaligned.
*/
@@ -244,7 +251,7 @@ public Packet getAddEntityPacket() {
public boolean hurt(DamageSource damageSource, float f) {
if (damageSource.getDirectEntity() instanceof Player player) { //Using getDirectEntity can allow for players to indirectly interact with controls, such as through primed TNT
if (this.level() instanceof ServerLevel serverLevel) {
- if(!player.level().isClientSide()) {
+ if (!player.level().isClientSide()) {
if (entityData.get(IS_DEAD)) {
return false;
}
@@ -252,7 +259,7 @@ public boolean hurt(DamageSource damageSource, float f) {
ItemStack itemStack = player.getMainHandItem();
- if(itemStack.is(TRItemRegistry.MALLET.get()) && !player.getCooldowns().isOnCooldown(TRItemRegistry.MALLET.get())){
+ if (itemStack.is(TRItemRegistry.MALLET.get()) && !player.getCooldowns().isOnCooldown(TRItemRegistry.MALLET.get())) {
player.getCooldowns().addCooldown(TRItemRegistry.MALLET.get(), 600);
playSound(TRSoundRegistry.MALLET.get());
itemStack.hurtAndBreak(15, player, (livingEntityx) -> {
@@ -314,7 +321,10 @@ public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand
public boolean isTickingDown() {
return getEntityData().get(TICKING_DOWN);
}
- /** Restores the control alignment points to a higher value so that it won't cause the Tardis to crash*/
+
+ /**
+ * Restores the control alignment points to a higher value so that it won't cause the Tardis to crash
+ */
public void realignControl() {
int currentHealth = this.entityData.get(CONTROL_HEALTH);
int nextHealth = currentHealth + 2;
@@ -467,17 +477,16 @@ public boolean isDesktopWaitingToGenerate(TardisLevelOperator operator) {
}
private boolean handleLeftClick(Player player, ServerLevel serverLevel) {
- if (!TardisLevelOperator.get(serverLevel).isPresent()){
+ if (!TardisLevelOperator.get(serverLevel).isPresent()) {
return false;
- }
- else {
+ } else {
TardisLevelOperator cap = TardisLevelOperator.get(serverLevel).get();
if (cap.getPilotingManager().getCurrentConsole() == null || cap.getPilotingManager().getCurrentConsole() != getConsoleBlockEntity()) {
cap.getPilotingManager().setCurrentConsole(this.getConsoleBlockEntity());
}
- if (!controlSpecification.control().canUseControl(cap, controlSpecification.control(), this)){
+ if (!controlSpecification.control().canUseControl(cap, controlSpecification.control(), this)) {
return false;
}
@@ -491,10 +500,9 @@ private boolean handleLeftClick(Player player, ServerLevel serverLevel) {
}
private boolean handleRightClick(Player player, ServerLevel serverLevel, InteractionHand interactionHand) {
- if (!TardisLevelOperator.get(serverLevel).isPresent()){
+ if (!TardisLevelOperator.get(serverLevel).isPresent()) {
return false;
- }
- else {
+ } else {
TardisLevelOperator cap = TardisLevelOperator.get(serverLevel).get();
if (cap.getPilotingManager().getCurrentConsole() == null || cap.getPilotingManager().getCurrentConsole() != getConsoleBlockEntity()) {
@@ -560,7 +568,9 @@ public boolean displayFireAnimation() {
return false;
}
- /** Gets the total amount of control alignment health points before a control will start causing the Tardis to crash*/
+ /**
+ * Gets the total amount of control alignment health points before a control will start causing the Tardis to crash
+ */
public int getTotalControlHealth() {
return this.totalControlHealth;
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java b/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java
index 7808eeb45..27c40c0aa 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java
@@ -28,9 +28,10 @@ public class HumEntry {
private String nameComponent;
/**
- * Generic constructor
- * @param identifier - Enter the registry name.
- * @param soundEventId - the underlying SoundEvent id
+ * Generic constructor
+ *
+ * @param identifier - Enter the registry name.
+ * @param soundEventId - the underlying SoundEvent id
* @param ambientSounds - List of ambient sounds that can play in addition to the Hum sound event
* @param nameComponent - the string that will be displayed. Can be either a language file translation key or a component
*/
@@ -43,6 +44,7 @@ public HumEntry(ResourceLocation identifier, ResourceLocation soundEventId, List
/**
* Convenience constructor that creates a default value for the nameComponent parameter by creating a gold coloured text component
+ *
* @param identifier
* @param soundEventId
* @param ambientSounds
@@ -52,9 +54,10 @@ public HumEntry(ResourceLocation identifier, ResourceLocation soundEventId, List
}
/**
- * Tardis Refined specific constructor
- * @param identifier - Enter the registry name. No need to add namespace because the TardisRefined namespace is already added
- * @param soundEventId - the underlying SoundEvent id
+ * Tardis Refined specific constructor
+ *
+ * @param identifier - Enter the registry name. No need to add namespace because the TardisRefined namespace is already added
+ * @param soundEventId - the underlying SoundEvent id
* @param ambientSounds - List of ambient sounds that can play in addition to the Hum sound event
*/
public HumEntry(String identifier, ResourceLocation soundEventId, List ambientSounds) {
@@ -62,8 +65,9 @@ public HumEntry(String identifier, ResourceLocation soundEventId, List codec() {
return CODEC;
}
- /** Gets the underlying SoundEvent's ID*/
+ /**
+ * Gets the underlying SoundEvent's ID
+ */
public ResourceLocation getSoundEventId() {
return soundEventId;
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java b/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java
index 24f6b3670..32bc81a3f 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java
@@ -16,56 +16,46 @@
public class TardisHums {
- private static final CodecJsonReloadListener RELOAD_LISTENER = createReloadListener();
-
- private static final Map DEFAULT_HUMS = new HashMap<>();
-
public static final HumEntry CAVE = new HumEntry("cave", TRSoundRegistry.HUM_CAVE.getId());
public static final HumEntry TOYOTA = new HumEntry("toyota", TRSoundRegistry.HUM_TOYOTA.getId());
public static final HumEntry CLASSIC = new HumEntry("classic", TRSoundRegistry.HUM_CLASSIC.getId());
public static final HumEntry VICTORIAN = new HumEntry("victorian", TRSoundRegistry.HUM_VICTORIAN.getId());
-
public static final HumEntry BASALT_DELTAS = new HumEntry(
"basalt_deltas",
SoundEvents.AMBIENT_BASALT_DELTAS_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_BASALT_DELTAS_ADDITIONS.value(), SoundEvents.AMBIENT_BASALT_DELTAS_MOOD.value())
);
-
public static final HumEntry CRIMSON_FOREST = new HumEntry(
"crimson_forest",
SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_CRIMSON_FOREST_ADDITIONS.value(), SoundEvents.AMBIENT_CRIMSON_FOREST_MOOD.value())
);
-
public static final HumEntry NETHER_WASTES = new HumEntry(
- "nether_wastes",
+ "nether_wastes",
SoundEvents.AMBIENT_NETHER_WASTES_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_NETHER_WASTES_ADDITIONS.value(), SoundEvents.AMBIENT_NETHER_WASTES_MOOD.value())
);
-
public static final HumEntry UNDER_WATER = new HumEntry(
"under_water",
SoundEvents.AMBIENT_UNDERWATER_LOOP.getLocation(),
createSoundList(SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS, SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE, SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE)
);
-
-
public static final HumEntry SOUL_SAND_VALLEY = new HumEntry(
"soul_sand_valley",
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS.value(), SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD.value())
);
-
public static final HumEntry WARPED_FOREST = new HumEntry(
"warped_forest",
SoundEvents.AMBIENT_WARPED_FOREST_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS.value(), SoundEvents.AMBIENT_WARPED_FOREST_MOOD.value())
);
-
public static final HumEntry AVIATRAX = new HumEntry(
"aviatrax",
- TRSoundRegistry.HUM_AVIATRAX.getId(),new ArrayList<>()
+ TRSoundRegistry.HUM_AVIATRAX.getId(), new ArrayList<>()
);
+ private static final CodecJsonReloadListener RELOAD_LISTENER = createReloadListener();
+ private static final Map DEFAULT_HUMS = new HashMap<>();
private static List createSoundList(SoundEvent... sounds) {
ArrayList soundList = new ArrayList<>();
diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/DrillItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/DrillItem.java
index 9fa5a74b2..93636056f 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/items/DrillItem.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/items/DrillItem.java
@@ -45,7 +45,6 @@ public InteractionResult useOn(UseOnContext useOnContext) {
}
-
private void destroyGrowthBlock(Level level, BlockPos pos) {
if (level.getBlockState(pos).getBlock() == TRBlockRegistry.FOOLS_STONE.get()) {
level.destroyBlock(pos, true);
diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/GlassesItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/GlassesItem.java
index 7b70ff15c..85799fe79 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/items/GlassesItem.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/items/GlassesItem.java
@@ -30,6 +30,7 @@ public SoundEvent getEquipSound() {
return Equipable.super.getEquipSound();
}
+ @Override
public InteractionResultHolder use(Level level, Player player, InteractionHand interactionHand) {
return this.swapWithEquipmentSlot(this, level, player, interactionHand);
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java
index 4614dc536..1545bfdb8 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java
@@ -44,16 +44,6 @@ public KeyItem(Properties properties) {
super(properties);
}
- @Override
- public Component getName(ItemStack itemStack) {
-
- if (getKeychain(itemStack).size() >= 2) {
- return Component.translatable(ModMessages.ITEM_KEYCHAIN);
- }
-
- return super.getName(itemStack);
- }
-
public static ItemStack addTardis(ItemStack itemStack, ResourceKey levelResourceKey) {
// Get the tag of the itemStack object
CompoundTag itemtag = itemStack.getOrCreateTag();
@@ -77,26 +67,6 @@ public static ItemStack addTardis(ItemStack itemStack, ResourceKey levelR
return itemStack;
}
- @Override
- public InteractionResultHolder use(Level level, Player player, InteractionHand interactionHand) {
-
- // Whistle Easter Egg: https://youtu.be/IqQsL79UpMs?t=526
- if(player.getOffhandItem().is(Items.GOAT_HORN) && !level.isClientSide){
- ArrayList> keychain = KeyItem.getKeychain(player.getMainHandItem());
- if(!keychain.isEmpty()) {
- var tardisLevel = Platform.getServer().getLevel(keychain.get(0));
- var operatorOptional = TardisLevelOperator.get(tardisLevel);
- var pilotManager = operatorOptional.get().getPilotingManager();
- if(!operatorOptional.get().getPilotingManager().isInRecovery()) {
- pilotManager.setTargetLocation(new TardisNavLocation(player.blockPosition(), player.getDirection().getOpposite(), (ServerLevel) player.level()));
- pilotManager.beginFlight(true, null);
- }
- }
- }
-
- return super.use(level, player, interactionHand);
- }
-
public static void setKeychain(ItemStack itemStack, ArrayList> levels) {
CompoundTag nbt = itemStack.getOrCreateTag();
ListTag keychain;
@@ -145,6 +115,36 @@ public static boolean keychainContains(ItemStack itemStack, ResourceKey l
return keychain.contains(levelResourceKey);
}
+ @Override
+ public Component getName(ItemStack itemStack) {
+
+ if (getKeychain(itemStack).size() >= 2) {
+ return Component.translatable(ModMessages.ITEM_KEYCHAIN);
+ }
+
+ return super.getName(itemStack);
+ }
+
+ @Override
+ public InteractionResultHolder use(Level level, Player player, InteractionHand interactionHand) {
+
+ // Whistle Easter Egg: https://youtu.be/IqQsL79UpMs?t=526
+ if (player.getOffhandItem().is(Items.GOAT_HORN) && !level.isClientSide) {
+ ArrayList> keychain = KeyItem.getKeychain(player.getMainHandItem());
+ if (!keychain.isEmpty()) {
+ var tardisLevel = Platform.getServer().getLevel(keychain.get(0));
+ var operatorOptional = TardisLevelOperator.get(tardisLevel);
+ var pilotManager = operatorOptional.get().getPilotingManager();
+ if (!operatorOptional.get().getPilotingManager().isInRecovery()) {
+ pilotManager.setTargetLocation(new TardisNavLocation(player.blockPosition(), player.getDirection().getOpposite(), (ServerLevel) player.level()));
+ pilotManager.beginFlight(true, null);
+ }
+ }
+ }
+
+ return super.use(level, player, interactionHand);
+ }
+
public boolean interactMonitor(ItemStack itemStack, Player player, ControlEntity control, InteractionHand interactionHand) {
if (control.level() instanceof ServerLevel serverLevel) {
@@ -155,7 +155,9 @@ public boolean interactMonitor(ItemStack itemStack, Player player, ControlEntity
setKeychain(itemStack, new ArrayList<>(List.of(serverLevel.dimension())));
- if (keychainContains(itemStack, tardis)) {return false;}
+ if (keychainContains(itemStack, tardis)) {
+ return false;
+ }
player.setItemInHand(interactionHand, addTardis(itemStack, tardis));
PlayerUtil.sendMessage(player, Component.translatable(ModMessages.MSG_KEY_BOUND, tardis.location().getPath()), true);
@@ -181,7 +183,7 @@ public InteractionResult useOn(UseOnContext context) {
Collections.rotate(keychain.subList(0, keychain.size()), -1);
setKeychain(context.getItemInHand(), keychain);
context.getPlayer().displayClientMessage(Component.translatable(ModMessages.MSG_KEY_CYCLED, keychain.get(0).location().getPath()), true);
- context.getLevel().playSound(null, context.getPlayer().blockPosition(), SoundEvents.UI_BUTTON_CLICK.value(), SoundSource.BLOCKS, 1,2);
+ context.getLevel().playSound(null, context.getPlayer().blockPosition(), SoundEvents.UI_BUTTON_CLICK.value(), SoundSource.BLOCKS, 1, 2);
}
}
}
@@ -205,7 +207,6 @@ public void appendHoverText(ItemStack itemStack, @Nullable Level level, List {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+
+ @Inject(method = "renderCrosshair(Lnet/minecraft/client/gui/GuiGraphics;)V", at = @At(value = "HEAD"), cancellable = true)
+ private void renderCrosshair(GuiGraphics guiGraphics, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+
+ @Inject(method = "renderSpyglassOverlay(Lnet/minecraft/client/gui/GuiGraphics;F)V", at = @At(value = "HEAD"), cancellable = true)
+ public void renderSpyglassOverlay(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+
+ @Inject(method = "renderExperienceBar(Lnet/minecraft/client/gui/GuiGraphics;I)V", at = @At(value = "HEAD"), cancellable = true)
+ public void renderExperienceBar(GuiGraphics guiGraphics, int i, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+
+ @Inject(method = "renderSpyglassOverlay(Lnet/minecraft/client/gui/GuiGraphics;F)V", at = @At(value = "HEAD"), cancellable = true)
+ protected void renderTextureOverlay(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+
+ @Inject(method = "renderPlayerHealth(Lnet/minecraft/client/gui/GuiGraphics;)V", at = @At(value = "HEAD"), cancellable = true)
+ private void renderPlayerHealth(GuiGraphics guiGraphics, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java
index 189cca8cf..5cb16ce9d 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java
@@ -4,10 +4,12 @@
import net.minecraft.client.player.LocalPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import whocraft.tardis_refined.client.TRKeybinds;
+import whocraft.tardis_refined.client.overlays.ExteriorViewOverlay;
import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo;
import whocraft.tardis_refined.common.network.messages.player.ExitTardisViewMessage;
@@ -17,6 +19,9 @@ public class LocalPlayerMixin {
@Shadow
public Input input;
+ @Unique
+ private long lastToggleInfoTime = 0;
+
@Inject(method = "aiStep()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getTutorial()Lnet/minecraft/client/tutorial/Tutorial;"))
private void inputEdit(CallbackInfo ci) {
LocalPlayer localPlayer = (LocalPlayer) (Object) this;
@@ -24,23 +29,29 @@ private void inputEdit(CallbackInfo ci) {
}
private void handleInput(LocalPlayer localPlayer, Input input) {
-
TardisPlayerInfo.get(localPlayer).ifPresent(tardisPlayerInfo -> {
- if(tardisPlayerInfo.isViewingTardis()){
+ if (tardisPlayerInfo.isViewingTardis()) {
blockMovement(input);
}
});
-
}
- private static void blockMovement(Input moveType) {
+ private void blockMovement(Input moveType) {
// Set all movement-related fields to false or 0.0F to block movement
- if(TRKeybinds.EXIT_EXTERIOR_VIEW.isDown()){
+ if (TRKeybinds.EXIT_EXTERIOR_VIEW.isDown()) {
new ExitTardisViewMessage().send();
return;
}
+ if (TRKeybinds.TOGGLE_INFO_EXTERIOR_VIEW.isDown()) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastToggleInfoTime >= 500) {
+ ExteriorViewOverlay.shouldRender = !ExteriorViewOverlay.shouldRender;
+ lastToggleInfoTime = currentTime;
+ }
+ }
+
moveType.right = false;
moveType.left = false;
moveType.down = false;
@@ -49,5 +60,4 @@ private static void blockMovement(Input moveType) {
moveType.shiftKeyDown = false;
moveType.leftImpulse = 0.0F;
}
-
-}
\ No newline at end of file
+}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/MultiplayerGameModeMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/MultiplayerGameModeMixin.java
index f381e2d41..6e36ab98a 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/mixin/MultiplayerGameModeMixin.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/MultiplayerGameModeMixin.java
@@ -14,16 +14,18 @@
@Mixin(MultiPlayerGameMode.class)
public class MultiplayerGameModeMixin {
- @Shadow @Final private Minecraft minecraft;
+ @Shadow
+ @Final
+ private Minecraft minecraft;
- @Inject(method = "destroyBlock", at = @At("HEAD"), cancellable = true)
- public void tr$destroyBlock(BlockPos blockPos, CallbackInfoReturnable cir) {
- ClientLevel level = this.minecraft.level;
- if (level == null) return;
+ @Inject(method = "destroyBlock", at = @At("HEAD"), cancellable = true)
+ public void tr$destroyBlock(BlockPos blockPos, CallbackInfoReturnable cir) {
+ ClientLevel level = this.minecraft.level;
+ if (level == null) return;
- if (MiscHelper.shouldCancelBreaking(level, null, blockPos, level.getBlockState(blockPos))) {
- cir.setReturnValue(false);
- cir.cancel();
- }
- }
+ if (MiscHelper.shouldCancelBreaking(level, null, blockPos, level.getBlockState(blockPos))) {
+ cir.setReturnValue(false);
+ cir.cancel();
+ }
+ }
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerEntityMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerEntityMixin.java
index 3ce351e11..45cee885b 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerEntityMixin.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerEntityMixin.java
@@ -25,7 +25,7 @@ private void move(Vec3 vec3, CallbackInfo info) {
}
});
- if(!player.level().isClientSide) return;
+ if (!player.level().isClientSide) return;
GravityClient.moveGravity(player, info);
}
@@ -33,11 +33,11 @@ private void move(Vec3 vec3, CallbackInfo info) {
@Inject(method = "tick()V", at = @At("TAIL"))
private void tick(CallbackInfo ci) {
Player player = (Player) (Object) this;
- if(GravityUtil.isInGravityShaft(player)){
+ if (GravityUtil.isInGravityShaft(player)) {
player.resetFallDistance();
}
- if(player.tickCount % 20 == 0 && !player.level().isClientSide){
+ if (player.tickCount % 20 == 0 && !player.level().isClientSide) {
TardisPlayerInfo.get(player).ifPresent(tardisPlayerInfo -> {
tardisPlayerInfo.syncToClients(null);
});
@@ -46,5 +46,4 @@ private void tick(CallbackInfo ci) {
}
-
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java
index e98606e32..01961f00e 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java
@@ -19,11 +19,11 @@ public class PlayerRenderMixin {
@Inject(method = "render(Lnet/minecraft/client/player/AbstractClientPlayer;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("HEAD"), cancellable = true)
private void render(AbstractClientPlayer abstractClientPlayer, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
- TardisPlayerInfo.get(abstractClientPlayer).ifPresent(tardisPlayerInfo -> {
- if (tardisPlayerInfo.isViewingTardis()) {
- ci.cancel();
- }
- });
+ TardisPlayerInfo.get(abstractClientPlayer).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/SpectatorGuiMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/SpectatorGuiMixin.java
new file mode 100644
index 000000000..b54f7dd31
--- /dev/null
+++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/SpectatorGuiMixin.java
@@ -0,0 +1,23 @@
+package whocraft.tardis_refined.common.mixin;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.spectator.SpectatorGui;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo;
+
+@Mixin(SpectatorGui.class)
+public class SpectatorGuiMixin {
+
+ @Inject(method = "renderHotbar(Lnet/minecraft/client/gui/GuiGraphics;)V", at = @At(value = "HEAD"), cancellable = true)
+ public void renderHotbar(GuiGraphics guiGraphics, CallbackInfo ci) {
+ TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
+ if (tardisPlayerInfo.isViewingTardis()) {
+ ci.cancel();
+ }
+ });
+ }
+}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/MessageS2C.java b/common/src/main/java/whocraft/tardis_refined/common/network/MessageS2C.java
index 48d3f9a44..53b5e3967 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/MessageS2C.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/MessageS2C.java
@@ -28,11 +28,11 @@ public void sendToAll() {
this.getType().getNetworkManager().sendToAllPlayers(this);
}
- public void sendToTracking(Entity entity){
+ public void sendToTracking(Entity entity) {
this.getType().getNetworkManager().sendToTracking(entity, this);
}
- public void sendToTracking(BlockEntity blockEntity){
+ public void sendToTracking(BlockEntity blockEntity) {
this.getType().getNetworkManager().sendToTracking(blockEntity, this);
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/NetworkManager.java b/common/src/main/java/whocraft/tardis_refined/common/network/NetworkManager.java
index 733ef1069..6bac15291 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/NetworkManager.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/NetworkManager.java
@@ -18,19 +18,19 @@
public abstract class NetworkManager {
- protected final ResourceLocation channelName;
public static final Map toServer = new HashMap<>();
+ protected final ResourceLocation channelName;
protected final Map toClient = new HashMap<>();
+ public NetworkManager(ResourceLocation channelName) {
+ this.channelName = channelName;
+ }
+
@ExpectPlatform
public static NetworkManager create(ResourceLocation channelName) {
throw new AssertionError();
}
- public NetworkManager(ResourceLocation channelName) {
- this.channelName = channelName;
- }
-
public MessageType registerS2C(String id, MessageDecoder decoder) {
var msgType = new MessageType(id, this, decoder, false);
this.toClient.put(id, msgType);
@@ -54,16 +54,16 @@ public MessageType registerC2S(String id, MessageDecoder decoder) {
public abstract void sendToTracking(BlockEntity entity, MessageS2C message);
public void sendToDimension(Level level, MessageS2C message) {
- if(!level.isClientSide) {
+ if (!level.isClientSide) {
for (Player player : level.players()) {
this.sendToPlayer((ServerPlayer) player, message);
}
}
}
- public void sendToAllPlayers(MessageS2C message){
+ public void sendToAllPlayers(MessageS2C message) {
MinecraftServer server = Platform.getServer();
- if(server == null) return;
+ if (server == null) return;
List players = server.getPlayerList().getPlayers();
players.forEach(entry -> sendToPlayer(entry, message));
}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java
index 0a57aa69b..f4623a4ed 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java
@@ -7,6 +7,7 @@
import whocraft.tardis_refined.common.network.messages.ChangeShellMessage;
import whocraft.tardis_refined.common.network.messages.EjectPlayerFromConsoleMessage;
import whocraft.tardis_refined.common.network.messages.hums.ChangeHumMessage;
+import whocraft.tardis_refined.common.network.messages.player.EndPlayerVortexSession;
import whocraft.tardis_refined.common.network.messages.player.ExitTardisViewMessage;
import whocraft.tardis_refined.common.network.messages.player.SyncTardisPlayerInfoMessage;
import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection;
@@ -21,8 +22,8 @@ public class TardisNetwork {
public static final NetworkManager NETWORK = NetworkManager.create(new ResourceLocation(TardisRefined.MODID, "channel"));
- public static MessageType TARDIS_EXIT, OPEN_SHELL_SELECT, SYNC_HUMS, OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C,
- REQUEST_SHELL_C2S, CLIENT_OPEN_COORDS_SCREEN, SERVER_OPEN_COORDS_SCREEN, CLIENT_OPEN_EDIT_COORDS_SCREEN, SERVER_OPEN_EDIT_COORDS_SCREEN, UPLOAD_WAYPOINT,
+ public static MessageType END_VORTEX_SESSION, TARDIS_EXIT, OPEN_SHELL_SELECT, SYNC_HUMS, OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C,
+ REQUEST_SHELL_C2S, CLIENT_OPEN_COORDS_SCREEN, SERVER_OPEN_COORDS_SCREEN, CLIENT_OPEN_EDIT_COORDS_SCREEN, SERVER_OPEN_EDIT_COORDS_SCREEN, UPLOAD_WAYPOINT,
EDIT_WAYPOINT, SET_WAYPOINT, CHANGE_HUM, REQUEST_WAYPOINTS, SYNC_DESKTOPS, SYNC_CONSOLE_PATTERNS, SYNC_SHELL_PATTERNS, SYNC_LEVELS, INT_REACTION,
OPEN_MONITOR, CHANGE_SHELL, CHANGE_DESKTOP, CANCEL_CHANGE_DESKTOP, UNLOCK_UPGRADE, EJECT_PLAYER, TARDIS_PLAYER_INFO;
@@ -42,6 +43,7 @@ public static void init() {
SYNC_HUMS = NETWORK.registerS2C("sync_hums", SyncHumsMessage::new);
UPGRADE_SCREEN_S2C = NETWORK.registerS2C("upgrade_screen_s2c", S2CDisplayUpgradeScreen::new);
TARDIS_PLAYER_INFO = NETWORK.registerS2C("tardis_player_info", SyncTardisPlayerInfoMessage::new);
+ END_VORTEX_SESSION = NETWORK.registerS2C("end_vortex_session", EndPlayerVortexSession::new);
// C2S Messages
CHANGE_SHELL = NETWORK.registerC2S("change_shell", ChangeShellMessage::new);
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/ChangeShellMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/ChangeShellMessage.java
index 1aca5db7a..0f74e1392 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/ChangeShellMessage.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/ChangeShellMessage.java
@@ -56,7 +56,7 @@ public void toBytes(FriendlyByteBuf buf) {
public void handle(MessageContext context) {
Optional level = Optional.ofNullable(context.getPlayer().getServer().levels.get(resourceKey));
level.flatMap(TardisLevelOperator::get).ifPresent(y -> {
- if(TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(y.getUpgradeHandler()) && y.getExteriorManager().hasEnoughFuelForShellChange()) {
+ if (TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(y.getUpgradeHandler()) && y.getExteriorManager().hasEnoughFuelForShellChange()) {
y.setShellTheme(this.shellTheme, pattern.id(), ShellChangeSources.GENERIC_UPDATE);
y.getPilotingManager().removeFuel(y.getExteriorManager().getFuelForShellChange());
} else {
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSession.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSession.java
new file mode 100644
index 000000000..32546d51d
--- /dev/null
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSession.java
@@ -0,0 +1,36 @@
+package whocraft.tardis_refined.common.network.messages.player;
+
+import net.minecraft.network.FriendlyByteBuf;
+import org.jetbrains.annotations.NotNull;
+import whocraft.tardis_refined.client.TardisClientLogic;
+import whocraft.tardis_refined.common.network.MessageContext;
+import whocraft.tardis_refined.common.network.MessageS2C;
+import whocraft.tardis_refined.common.network.MessageType;
+import whocraft.tardis_refined.common.network.TardisNetwork;
+
+public class EndPlayerVortexSession extends MessageS2C {
+
+ public EndPlayerVortexSession() {
+ }
+
+ public EndPlayerVortexSession(FriendlyByteBuf friendlyByteBuf) {
+ }
+
+
+ @Override
+ public @NotNull MessageType getType() {
+ return TardisNetwork.END_VORTEX_SESSION;
+ }
+
+ @Override
+ public void toBytes(FriendlyByteBuf buf) {
+
+ }
+
+ @Override
+ public void handle(MessageContext context) {
+ TardisClientLogic.handleClient();
+ }
+
+
+}
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java
index 54d534d5b..2c8eabff5 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java
@@ -17,11 +17,10 @@
import java.util.List;
import java.util.Map;
-public class SyncConsolePatternsMessage extends MessageS2C{
-
- protected Map> patterns = new HashMap<>();
+public class SyncConsolePatternsMessage extends MessageS2C {
protected final UnboundedMapCodec> MAPPER = Codec.unboundedMap(ResourceLocation.CODEC, ConsolePattern.CODEC.listOf().xmap(List::copyOf, List::copyOf));
+ protected Map> patterns = new HashMap<>();
public SyncConsolePatternsMessage(Map> patterns) {
this.patterns = patterns;
diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java
index 0e57359ae..ae6975b26 100644
--- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java
+++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java
@@ -17,10 +17,10 @@
public class SyncDesktopsMessage extends MessageS2C {
- private Map desktops = new HashMap<>();
//We use an unboundedMapCodec. However it is limited in that it can only parse objects whose keys can be serialised to a string, such as ResourceLocation
//E.g. If you used an int as a key, the unboundedMapCodec will not parse it and will error.
private static final Codec