Make ping position text clearer
This commit is contained in:
parent
f908d04034
commit
4b0a964369
@ -1,7 +1,7 @@
|
||||
package me.bionicbeanie.mods.savecoords;
|
||||
|
||||
import me.bionicbeanie.mods.savecoords.model.PlayerRawPosition;
|
||||
import me.bionicbeanie.mods.savecoords.model.PlayerPosition;
|
||||
|
||||
public interface INetherCalculator {
|
||||
PlayerRawPosition convert(PlayerRawPosition position);
|
||||
PlayerPosition convert(PlayerPosition position);
|
||||
}
|
||||
|
||||
@ -78,9 +78,9 @@ public class DIContainer {
|
||||
MinecraftClient minecraftClient = MinecraftClient.getInstance();
|
||||
fileStore = Factory.createFileStore(minecraftClient.runDirectory.getAbsolutePath());
|
||||
guiController = new GuiController(minecraftClient);
|
||||
playerLocator = Factory.CreatePlayerLocator(minecraftClient);
|
||||
keyBinds = Factory.CreateKeyBinds(fileStore);
|
||||
dimensionAware = Factory.CreateDimensionAware(minecraftClient);
|
||||
playerLocator = Factory.CreatePlayerLocator(minecraftClient, dimensionAware);
|
||||
keyBinds = Factory.CreateKeyBinds(fileStore);
|
||||
netherCalculator = Factory.CreateNetherCalculator(dimensionAware);
|
||||
modGui = new SaveCoordinatesGui(fileStore, playerLocator, dimensionAware, keyBinds, guiController,
|
||||
netherCalculator);
|
||||
|
||||
@ -179,12 +179,13 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.convertButton.setOnClick(() -> setRawPosition(netherCalculator.convert(position)));
|
||||
}
|
||||
|
||||
private void setRawPosition(PlayerRawPosition position) {
|
||||
private void setRawPosition(PlayerPosition position) {
|
||||
|
||||
this.icon.setImage(ResourceUtils.getIdentifier(position.getWorldDimension()));
|
||||
this.coordinates
|
||||
.setText(new LiteralText(position.getX() + ", " + position.getY() + ", " + position.getZ()));
|
||||
this.convertButton.setOnClick(() -> setRawPosition(netherCalculator.convert(position)));
|
||||
this.pingButton.setOnClick(() -> onPing.accept(position));
|
||||
this.coordinateConvertState = !coordinateConvertState;
|
||||
this.convertButton.setIcon(ResourceUtils.createConvertIcon(coordinateConvertState));
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ public class Factory {
|
||||
return new FileStore(baseDirectory);
|
||||
}
|
||||
|
||||
public static IPlayerLocator CreatePlayerLocator(MinecraftClient client) {
|
||||
return new PlayerLocator(client);
|
||||
public static IPlayerLocator CreatePlayerLocator(MinecraftClient client, IDimensionAware dimensionAware) {
|
||||
return new PlayerLocator(client, dimensionAware);
|
||||
}
|
||||
|
||||
public static IKeyBinds CreateKeyBinds(IFileStore fileStore) {
|
||||
|
||||
@ -3,6 +3,7 @@ package me.bionicbeanie.mods.savecoords.impl;
|
||||
import me.bionicbeanie.mods.savecoords.IDimensionAware;
|
||||
import me.bionicbeanie.mods.savecoords.IDimensionAware.IDimension;
|
||||
import me.bionicbeanie.mods.savecoords.INetherCalculator;
|
||||
import me.bionicbeanie.mods.savecoords.model.PlayerPosition;
|
||||
import me.bionicbeanie.mods.savecoords.model.PlayerRawPosition;
|
||||
|
||||
class NetherCalculator implements INetherCalculator {
|
||||
@ -28,19 +29,24 @@ class NetherCalculator implements INetherCalculator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerRawPosition convert(PlayerRawPosition position) {
|
||||
public PlayerPosition convert(PlayerPosition position) {
|
||||
IDimension dimension = dimensionAware.getDimension(position.getWorldDimension());
|
||||
|
||||
PlayerRawPosition rawPosition = null;
|
||||
|
||||
if (dimensionAware.isOverworld(dimension)) {
|
||||
return new PlayerRawPosition(position.getX() / MULTIPLIER, position.getY(), position.getZ() / MULTIPLIER,
|
||||
rawPosition = new PlayerRawPosition(position.getX() / MULTIPLIER, position.getY(), position.getZ() / MULTIPLIER,
|
||||
nether.getName());
|
||||
}
|
||||
|
||||
if (dimensionAware.isNether(dimension)) {
|
||||
return new PlayerRawPosition(position.getX() * MULTIPLIER, position.getY(), position.getZ() * MULTIPLIER,
|
||||
rawPosition = new PlayerRawPosition(position.getX() * MULTIPLIER, position.getY(), position.getZ() * MULTIPLIER,
|
||||
overworld.getName());
|
||||
}
|
||||
|
||||
if(rawPosition != null) {
|
||||
return new PlayerPosition(position.getId(), rawPosition, position.getLocationName(), position.getPositionMetadata());
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package me.bionicbeanie.mods.savecoords.impl;
|
||||
|
||||
import me.bionicbeanie.mods.savecoords.IDimensionAware;
|
||||
import me.bionicbeanie.mods.savecoords.IPlayerLocator;
|
||||
import me.bionicbeanie.mods.savecoords.model.PlayerRawPosition;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@ -8,9 +9,11 @@ import net.minecraft.util.math.Vec3d;
|
||||
class PlayerLocator implements IPlayerLocator {
|
||||
|
||||
private MinecraftClient client;
|
||||
private IDimensionAware dimensionAware;
|
||||
|
||||
public PlayerLocator(MinecraftClient client) {
|
||||
public PlayerLocator(MinecraftClient client, IDimensionAware dimensionAware) {
|
||||
this.client = client;
|
||||
this.dimensionAware = dimensionAware;
|
||||
}
|
||||
|
||||
public PlayerRawPosition locate() {
|
||||
@ -19,7 +22,7 @@ class PlayerLocator implements IPlayerLocator {
|
||||
long y = Math.round(pos.y);
|
||||
long z = Math.round(pos.z);
|
||||
|
||||
String worldDimension = client.player.getEntityWorld().getRegistryKey().getValue().toString();
|
||||
String worldDimension = this.dimensionAware.getCurrentDimension().getName();
|
||||
|
||||
return new PlayerRawPosition(x, y, z, worldDimension);
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class PlayerPosition extends PlayerRawPosition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.locationName + " in [ " + this.getWorldDimension() + " ] at [ " + this.getX() + ", " + this.getY()
|
||||
+ ", " + this.getZ() + " ]";
|
||||
return this.locationName + " in " + this.getWorldDimension() + " >>> " + this.getX() + ", " + this.getY()
|
||||
+ ", " + this.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class PlayerRawPosition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "I'm in [ " + worldDimension + " ] at [ " + x + ", " + y + ", " + z + " ]";
|
||||
return worldDimension + " >>> " + x + ", " + y + ", " + z;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user