Skip to content

Commit

Permalink
Fixed key logic (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
CommandrMoose authored May 8, 2024
1 parent 467c5de commit 16f16ed
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,14 @@ public boolean interactMonitor(ItemStack itemStack, Player player, ControlEntity
if (control.controlSpecification().control() == TRControlRegistry.MONITOR.get()) {


AtomicBoolean canTARDISTakeItem = new AtomicBoolean(false);
TardisLevelOperator.get(serverLevel).ifPresent((operator) -> {
if (operator.getTardisState() != TardisLevelOperator.STATE_EYE_OF_HARMONY || operator.getPilotingManager().isOutOfFuel()) {
PlayerUtil.sendMessage(player, ModMessages.HARDWARE_OFFLINE, true);
canTARDISTakeItem.set(false);
} else {
canTARDISTakeItem.set(true);
}
});

if (!keychainContains(itemStack, tardis) || !canTARDISTakeItem.get()) {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);
player.playSound(SoundEvents.PLAYER_LEVELUP, 1, 0.5F);


return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public OpenMonitorMessage(boolean desktopGenerating, TardisNavLocation currentLo

public OpenMonitorMessage(FriendlyByteBuf friendlyByteBuf) {
this.desktopGenerating = friendlyByteBuf.readBoolean();
this.currentLocation = TardisNavLocation.deserialise(friendlyByteBuf.readNbt());
this.targetLocation = TardisNavLocation.deserialise(friendlyByteBuf.readNbt());
this.currentLocation = TardisNavLocation.deserialize(friendlyByteBuf.readNbt());
this.targetLocation = TardisNavLocation.deserialize(friendlyByteBuf.readNbt());
this.upgradeHandlerNbt = friendlyByteBuf.readNbt();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public S2COpenCoordinatesDisplayMessage(List<ResourceKey<Level>> waypoints, Coor

public S2COpenCoordinatesDisplayMessage(FriendlyByteBuf friendlyByteBuf) {
CompoundTag tardisNav = friendlyByteBuf.readNbt();
tardisNavLocation = TardisNavLocation.deserialise(tardisNav);
tardisNavLocation = TardisNavLocation.deserialize(tardisNav);
coordInputType = CoordInputType.valueOf(friendlyByteBuf.readUtf());
levels = new ArrayList<>();
int size = friendlyByteBuf.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public UploadWaypointMessage(TardisNavLocation tardisNavLocation, CoordInputType

public UploadWaypointMessage(FriendlyByteBuf buf) {
CompoundTag tardisNav = buf.readNbt();
this.tardisNavLocation = TardisNavLocation.deserialise(tardisNav);
this.tardisNavLocation = TardisNavLocation.deserialize(tardisNav);
this.coordInputType = CoordInputType.valueOf(buf.readUtf());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ public static void buildAirlockEntranceFromStructure(StructureTemplate template,
}
}
}

public static void generateEssentialCorridors(ServerLevel serverLevel) {

Optional<StructureTemplate> structureNBT = serverLevel.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "rooms/eye_of_harmony"));
structureNBT.ifPresent(structure -> {
BlockPos offsetPosition = new BlockPos(EYE_OF_HARMONY_PLACEMENT);
structure.placeInWorld(serverLevel.getLevel(), offsetPosition, offsetPosition, new StructurePlaceSettings(), serverLevel.getLevel().random, Block.UPDATE_NONE);
});

}


public static void generateArsTree(TardisLevelOperator tardisLevelOperator, ServerLevel level) {
if (!currentArsStage.equals("one") && Objects.equals(tardisLevelOperator.getUpgradeHandler().getProgressLevel(), currentArsStage))
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package whocraft.tardis_refined.common.tardis;

import com.sun.jna.platform.win32.Guid;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
Expand All @@ -11,8 +10,6 @@
import net.minecraft.world.level.Level;
import whocraft.tardis_refined.common.util.Platform;

import java.util.UUID;

/**
* TardisNavLocation
* Co-ordinates that represent position, rotation, level and name.
Expand Down Expand Up @@ -108,7 +105,7 @@ public void setName(String name) {
this.name = name;
}

public static TardisNavLocation deserialise(CompoundTag tag) {
public static TardisNavLocation deserialize(CompoundTag tag) {
TardisNavLocation loc = new TardisNavLocation(BlockPos.of(tag.getLong("pos")), Direction.values()[tag.getInt("dir")], ResourceKey.create(Registries.DIMENSION, new ResourceLocation(tag.getString("dim"))));

if (tag.contains("name"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package whocraft.tardis_refined.common.tardis;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;

import java.util.UUID;

Expand Down Expand Up @@ -37,7 +32,7 @@ public void setLocation(TardisNavLocation location) {
}

public static TardisWaypoint deserialise(CompoundTag tag) {
TardisNavLocation loc = TardisNavLocation.deserialise(tag.getCompound("location"));
TardisNavLocation loc = TardisNavLocation.deserialize(tag.getCompound("location"));
UUID id = tag.getUUID("id");

TardisWaypoint waypoint = new TardisWaypoint(id, loc);
Expand Down

0 comments on commit 16f16ed

Please sign in to comment.