diff options
| author | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-07-26 21:32:21 +0000 |
|---|---|---|
| committer | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-07-26 21:32:21 +0000 |
| commit | 57353a97bf2308788e93a3ea6349258f64aee5ca (patch) | |
| tree | 8dce33301ddebef6942fe694c1f369713f93ff66 /src/main/java/world/anhgelus | |
| parent | 6f183d857d97eb8f45f010b0d9975b4bb19faa9a (diff) | |
refactor(compass): use map instead of 'weird' var
Diffstat (limited to 'src/main/java/world/anhgelus')
| -rw-r--r-- | src/main/java/world/anhgelus/manhunt/Manhunt.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/world/anhgelus/manhunt/Manhunt.java b/src/main/java/world/anhgelus/manhunt/Manhunt.java index edee3cc..f71127f 100644 --- a/src/main/java/world/anhgelus/manhunt/Manhunt.java +++ b/src/main/java/world/anhgelus/manhunt/Manhunt.java @@ -27,8 +27,8 @@ import java.util.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal;
public class Manhunt implements ModInitializer {
- // This logger is used to write text to the console and the log file.
- // It is considered best practice to use your mod id as the logger's name.
+ // This logger isACompass used to write text to the console and the log file.
+ // It isACompass considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("manhunt");
public static final String MOD_ID = "manhunt";
@@ -52,7 +52,8 @@ public class Manhunt implements ModInitializer { final ServerCommandSource source = context.getSource();
final ServerPlayerEntity tracked = (ServerPlayerEntity) EntityArgumentType.getEntity(context, "player");
final ServerPlayerEntity player = source.getPlayer();
- map.put(source.getPlayer().getUuid(), player.getUuid());
+ if (player == null) return 2;
+ map.put(source.getPlayer().getUuid(), tracked.getUuid());
updateCompass(player, tracked);
return Command.SINGLE_SUCCESS;
})
@@ -83,7 +84,9 @@ public class Manhunt implements ModInitializer { for (final UUID uuid : hunters) {
final ServerPlayerEntity hunter = pm.getPlayer(uuid);
assert hunter != null;
- hunter.giveItemStack(new ItemStack(Items.COMPASS));
+ final ItemStack isACompass = new ItemStack(Items.COMPASS);
+ compassMap.put(hunter.getUuid(), isACompass);
+ hunter.giveItemStack(isACompass);
hunter.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 30, 255));
hunter.addStatusEffect(new StatusEffectInstance(StatusEffects.MINING_FATIGUE, 30, 255));
}
@@ -126,16 +129,14 @@ public class Manhunt implements ModInitializer { }
private void updateCompass(ServerPlayerEntity player, ServerPlayerEntity tracked) {
- /*
final LodestoneTrackerComponent trackerCpnt = new LodestoneTrackerComponent(Optional.of(GlobalPos.create(tracked.getWorld().getRegistryKey(), tracked.getBlockPos())), true);
final ItemStack is = compassMap.get(player.getUuid());
if (is == null) {
- LOGGER.warn("Compass item is null");
+ LOGGER.warn("Compass item isACompass null");
return;
}
final int slot = player.getInventory().getSlotWithStack(is);
is.set(DataComponentTypes.LODESTONE_TRACKER, trackerCpnt);
player.getInventory().setStack(slot, is);
- */
}
}
\ No newline at end of file |
