Skip to content

Commit

Permalink
Started Teleport enchancements and many fixes
Browse files Browse the repository at this point in the history
-Waypoint translation entries
-Internal Door blocks not using proper inheritance and having dummy entries actually registered as a result
  • Loading branch information
50ap5ud5 committed Dec 26, 2023
1 parent 0e8fe8e commit f65da2e
Show file tree
Hide file tree
Showing 46 changed files with 788 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import whocraft.tardis_refined.common.blockentity.door.TardisInternalDoor;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.capability.upgrades.Upgrade;
import whocraft.tardis_refined.common.entity.ControlEntity;
Expand All @@ -24,9 +26,15 @@ public class TardisEvents {
}
}));

public static final Event<TardisEntry> TARDIS_ENTRY_EVENT = new Event<>(TardisEntry.class, listeners -> (tardisLevelOperator, shell, player, externalPos, level, direction) -> {
public static final Event<TardisEntry> TARDIS_ENTRY_EVENT = new Event<>(TardisEntry.class, listeners -> (tardisLevelOperator, livingEntity, source, destination) -> {
for (TardisEntry listener : listeners) {
listener.onEnterTardis(tardisLevelOperator, shell, player, externalPos, level, direction);
listener.onEnterTardis(tardisLevelOperator, livingEntity, source, destination);
}
});

public static final Event<TardisExit> TARDIS_EXIT_EVENT = new Event<>(TardisExit.class, listeners -> (tardisLevelOperator, livingEntity, source, destination) -> {
for (TardisExit listener : listeners) {
listener.onExitTardis(tardisLevelOperator, livingEntity, source, destination);
}
});

Expand Down Expand Up @@ -175,15 +183,28 @@ public interface ShellChange {
@FunctionalInterface
public interface TardisEntry {
/**
* Called when a player enters a TARDIS.
* Called when a living entity enters a TARDIS.
*
* @param tardisLevelOperator The Tardis capability
* @param livingEntity The living entity who is entering the TARDIS.
* @param sourceLocation The position, level and direction of the exterior of the TARDIS.
* @param destinationLocation The position, level and direction of the internal door of the TARDIS.
*/
void onEnterTardis(TardisLevelOperator tardisLevelOperator, LivingEntity livingEntity, TardisNavLocation sourceLocation, TardisNavLocation destinationLocation);

}

@FunctionalInterface
public interface TardisExit {
/**
* Called when a living entity exits a TARDIS.
*
* @param shell The exterior shell of the TARDIS.
* @param player The player who is entering the TARDIS.
* @param externalPos The position of the exterior of the TARDIS.
* @param level The level where the TARDIS is located.
* @param direction The direction the player is facing when entering the TARDIS.
* @param tardisLevelOperator The Tardis capability
* @param livingEntity The living entity who is exiting the TARDIS.
* @param sourceLocation The position, level and direction of the internal door of the TARDIS.
* @param destinationLocation The position, level and direction of the exterior of the TARDIS.
*/
void onEnterTardis(TardisLevelOperator tardisLevelOperator, ExteriorShell shell, Player player, BlockPos externalPos, Level level, Direction direction);
void onExitTardis(TardisLevelOperator tardisLevelOperator, LivingEntity livingEntity, TardisNavLocation sourceLocation, TardisNavLocation destinationLocation);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import whocraft.tardis_refined.client.ModelRegistry;
import whocraft.tardis_refined.client.model.blockentity.shell.internal.door.RootShellDoorModel;
import whocraft.tardis_refined.common.block.shell.RootedShellBlock;
import whocraft.tardis_refined.common.blockentity.desktop.door.RootShellDoorBlockEntity;
import whocraft.tardis_refined.common.blockentity.door.RootShellDoorBlockEntity;

public class RootShellDoorRenderer implements BlockEntityRenderer<RootShellDoorBlockEntity>, BlockEntityRendererProvider<RootShellDoorBlockEntity> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class WaypointManageScreen extends Screen {
private SpriteIconButton onSaveWaypoint;

public WaypointManageScreen(List<ResourceKey<Level>> worlds, CoordInputType coordInputType, TardisNavLocation tardisNavLocation) {
super(Component.translatable(coordInputType == CoordInputType.WAYPOINT ? ModMessages.UI_MONITOR_UPLOAD_WAYPOINTS : ModMessages.UI_MONITOR_UPLOAD_COORDS)); //todo translatable
super(Component.translatable(coordInputType == CoordInputType.WAYPOINT ? ModMessages.UI_MONITOR_UPLOAD_WAYPOINTS : ModMessages.UI_MONITOR_UPLOAD_COORDS));
this.worlds = worlds;
this.coordInputType = coordInputType;
this.tardisNavLocation = tardisNavLocation;
Expand All @@ -72,10 +72,10 @@ protected void init() {
xPosition = this.width / 2 - 95;

// Upload Data Button
Component uploadLiteral = Component.translatable(ModMessages.UI_MONITOR_UPLOAD);
Component uploadLiteral = Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_UPLOAD);


onSaveWaypoint = this.addRenderableWidget(CommonTRWidgets.imageButton(this.width / 2 - 40, Component.translatable("Submit"), (arg) -> {
onSaveWaypoint = this.addRenderableWidget(CommonTRWidgets.imageButton(this.width / 2 - 40, Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_SUBMIT), (arg) -> {
if (issues.isEmpty()) {
prepareForUpload();
new UploadWaypointMessage(tardisNavLocation, coordInputType).send();
Expand All @@ -87,10 +87,10 @@ protected void init() {


if (coordInputType == CoordInputType.WAYPOINT) {
this.waypointName = new EditBox(this.font, xPosition, yPosition, this.width / 2 - 40, widgetHeight, this.waypointName, Component.translatable("selectWorld.search"));
this.waypointName = new EditBox(this.font, xPosition, yPosition, this.width / 2 - 40, widgetHeight, this.waypointName, Component.translatable(ModMessages.VANILLA_SELECT_WORLD));
this.waypointName.setResponder((string) -> {
if (string.isEmpty()) {
issues.put("waypoint_error", "Invalid Waypoint name");
issues.put("waypoint_error", Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_NAME).getString());
return;
} else {
tardisNavLocation.setName(string);
Expand All @@ -103,45 +103,45 @@ protected void init() {
}


this.xCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.xCoord, Component.translatable("selectWorld.search"));
this.xCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.xCoord, Component.translatable(ModMessages.VANILLA_SELECT_WORLD));
this.xCoord.setResponder((string) -> {
try {
int newValue = Integer.parseInt(string);
tardisNavLocation.setX(newValue);
issues.remove("x_error");
} catch (NumberFormatException e) {
issues.put("x_error", "Invalid X Value!");
issues.put("x_error", Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_X).getString());
}
});

xPosition += widgetLengths - 35 + 15;

this.yCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.yCoord, Component.translatable("selectWorld.search"));
this.yCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.yCoord, Component.translatable(ModMessages.VANILLA_SELECT_WORLD));
this.yCoord.setResponder((string) -> {
try {
int newValue = Integer.parseInt(string);
tardisNavLocation.setY(newValue);
issues.remove("y_error");
} catch (NumberFormatException e) {
issues.put("y_error", "Invalid Y Value!");
issues.put("y_error", Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_Y).getString());
}
});

xPosition += widgetLengths - 35 + 15;

this.zCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.zCoord, Component.translatable("selectWorld.search"));
this.zCoord = new EditBox(this.font, xPosition, yPosition, widgetLengths - 30, widgetHeight, this.zCoord, Component.translatable(ModMessages.VANILLA_SELECT_WORLD));
this.zCoord.setResponder((string) -> {
try {
int newValue = Integer.parseInt(string);
tardisNavLocation.setZ(newValue);
issues.remove("z_error");
} catch (NumberFormatException e) {
issues.put("z_error", "Invalid Z Value!");
issues.put("z_error", Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_Z).getString());
}
});


//Buttons
//Buttons
xPosition = this.width / 2 - 95;

// Set Dimension Button
Expand All @@ -150,7 +150,7 @@ protected void init() {
return Component.literal(MiscHelper.getCleanDimensionName(dimension));
});
dimBuilder.withValues(this.worlds);
levelButton = dimBuilder.create(xPosition, yPosition + 100 - 45, this.width / 2 - 40, widgetHeight, Component.literal("Dimension"));
levelButton = dimBuilder.create(xPosition, yPosition + 100 - 45, this.width / 2 - 40, widgetHeight, Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_DIMENSION));
this.addWidget(levelButton);

// Direction Button
Expand All @@ -162,7 +162,7 @@ protected void init() {
return Component.literal(direction.getName().substring(0, 1).toUpperCase() + direction.getName().substring(1));
});
builder.withValues(directionCollection);
directionButton = builder.create(xPosition, yPosition + 100 - 65, this.width / 2 - 40, widgetHeight, Component.literal("Direction"));
directionButton = builder.create(xPosition, yPosition + 100 - 65, this.width / 2 - 40, widgetHeight, Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_DIRECTION));
addWidget(directionButton);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import whocraft.tardis_refined.command.arguments.DesktopArgumentType;
import whocraft.tardis_refined.command.arguments.ShellArgumentType;
import whocraft.tardis_refined.common.tardis.themes.DesktopTheme;
import whocraft.tardis_refined.common.util.CommandHelper;
import whocraft.tardis_refined.common.util.TardisHelper;
import whocraft.tardis_refined.constants.ModMessages;

Expand Down Expand Up @@ -48,10 +47,7 @@ private static int createTardis(CommandContext<CommandSourceStack> context) thro
//Create a Level Key with a randomised UUID
ResourceKey<Level> generatedLevelKey = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(TardisRefined.MODID, UUID.randomUUID().toString()));

ResourceLocation levelId = generatedLevelKey.location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(generatedLevelKey.location());

context.getSource().sendSystemMessage(Component.translatable(ModMessages.CMD_CREATE_TARDIS_IN_PROGRESS, tardisId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private static boolean teleportToInterior(TardisLevelOperator tardisLevelOperato
if (tardisLevelOperator.getInternalDoor() != null) {
BlockPos pos = tardisLevelOperator.getInternalDoor().getDoorPosition();
pos = pos.relative(tardisLevelOperator.getInternalDoor().getEntryRotation(), 1);
TRTeleporter.performTeleport(entity, finalTpLevel, pos.getX(), pos.getY(), pos.getZ(), entity.getYRot(), entity.getXRot());
TRTeleporter.performTeleport(entity, finalTpLevel, pos.getX(), pos.getY(), pos.getZ(), entity.getYHeadRot(), entity.getXRot());
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import net.minecraft.commands.arguments.DimensionArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import org.spongepowered.asm.mixin.Mutable;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler;
import whocraft.tardis_refined.common.util.CommandHelper;
import whocraft.tardis_refined.common.util.TardisHelper;
import whocraft.tardis_refined.constants.ModMessages;

public class LevelCommand {
Expand Down Expand Up @@ -54,10 +53,7 @@ public class LevelCommand {
private static int getDimensionPoints(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
int points = tardisLevelOperator.getUpgradeHandler().getUpgradePoints();
Expand All @@ -72,10 +68,7 @@ private static int setDimensionPoints(CommandContext<CommandSourceStack> context
int amount = IntegerArgumentType.getInteger(context, "amount");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
UpgradeHandler upgradeHandler = tardisLevelOperator.getUpgradeHandler();
Expand All @@ -92,10 +85,7 @@ private static int addDimensionPoints(CommandContext<CommandSourceStack> context
int amount = IntegerArgumentType.getInteger(context, "amount");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
UpgradeHandler upgradeHandler = tardisLevelOperator.getUpgradeHandler();
Expand All @@ -112,10 +102,7 @@ private static int addDimensionXp(CommandContext<CommandSourceStack> context) th
int amount = IntegerArgumentType.getInteger(context, "amount");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
UpgradeHandler upgradeHandler = tardisLevelOperator.getUpgradeHandler();
Expand All @@ -130,10 +117,7 @@ private static int addDimensionXp(CommandContext<CommandSourceStack> context) th
private static int getDimensionXp(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
int xp = tardisLevelOperator.getUpgradeHandler().getUpgradeXP();
Expand All @@ -148,10 +132,7 @@ private static int setDimensionXp(CommandContext<CommandSourceStack> context) th
int amount = IntegerArgumentType.getInteger(context, "amount");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
tardisLevelOperator.getUpgradeHandler().setUpgradeXP(amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import net.minecraft.commands.arguments.DimensionArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import whocraft.tardis_refined.command.arguments.UpgradeArgumentType;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.capability.upgrades.Upgrade;
import whocraft.tardis_refined.common.util.CommandHelper;
import whocraft.tardis_refined.common.util.TardisHelper;
import whocraft.tardis_refined.constants.ModMessages;

public class UpgradesCommand {
Expand Down Expand Up @@ -43,10 +43,7 @@ private static int setUpgradeLocked(CommandContext<CommandSourceStack> context)
Upgrade upgrade = UpgradeArgumentType.getUpgrade(context, "upgrade");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
tardisLevelOperator.getUpgradeHandler().lockUpgrade(upgrade);
Expand All @@ -61,10 +58,7 @@ private static int setUpgradeUnlocked(CommandContext<CommandSourceStack> context
Upgrade upgrade = UpgradeArgumentType.getUpgrade(context, "upgrade");
ServerLevel dimension = DimensionArgument.getDimension(context, "tardis");

ResourceLocation levelId = dimension.dimension().location();
String id = levelId.toString();
String displayId = levelId.getPath().substring(0, 5);
MutableComponent tardisId = CommandHelper.createComponentWithTooltip(displayId, id);
MutableComponent tardisId = TardisHelper.createTardisIdComponent(dimension.dimension().location());

TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> {
tardisLevelOperator.getUpgradeHandler().unlockUpgrade(upgrade);
Expand Down
Loading

0 comments on commit f65da2e

Please sign in to comment.