Skip to content

Commit

Permalink
Added rule teleportCommandCrossDimensionSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed May 21, 2023
1 parent d2713b2 commit dd5444b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
20 changes: 17 additions & 3 deletions patches/net/minecraft/command/impl/TeleportCommand.java.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
--- a/net/minecraft/command/impl/TeleportCommand.java
+++ b/net/minecraft/command/impl/TeleportCommand.java
@@ -1,5 +1,6 @@
@@ -1,5 +1,7 @@
package net.minecraft.command.impl;

+import carpet.helpers.CommandPermissionHelper;
+import carpet.settings.CarpetSettings;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.LiteralCommandNode;
@@ -30,11 +31,10 @@
@@ -30,11 +32,10 @@
{
public static void register(CommandDispatcher<CommandSource> dispatcher)
{
Expand All @@ -22,7 +23,7 @@
return teleportToPos(p_198807_0_.getSource(), EntityArgument.getEntities(p_198807_0_, "targets"), p_198807_0_.getSource().getWorld(), Vec3Argument.getLocation(p_198807_0_, "location"), (ILocationArgument)null, (TeleportCommand.Facing)null);
}).then(Commands.argument("rotation", RotationArgument.rotation()).executes((p_198811_0_) ->
{
@@ -58,10 +58,9 @@
@@ -58,17 +59,21 @@
{
return teleportToEntity(p_200562_0_.getSource(), Collections.singleton(p_200562_0_.getSource().assertIsEntity()), EntityArgument.getEntity(p_200562_0_, "destination"));
})));
Expand All @@ -36,3 +37,16 @@
}

private static int teleportToEntity(CommandSource source, Collection <? extends Entity > targets, Entity destination)
{
for (Entity entity : targets)
{
- teleport(source, entity, source.getWorld(), destination.posX, destination.posY, destination.posZ, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class), destination.rotationYaw, destination.rotationPitch, (TeleportCommand.Facing)null);
+ // TISCM teleportCommandCrossDimensionSupport
+ WorldServer destWorld = CarpetSettings.teleportCommandCrossDimensionSupport ?
+ (WorldServer)destination.world : // modded
+ source.getWorld(); // vanilla
+
+ teleport(source, entity, destWorld, destination.posX, destination.posY, destination.posZ, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class), destination.rotationYaw, destination.rotationPitch, (TeleportCommand.Facing)null);
}

if (targets.size() == 1)
10 changes: 10 additions & 0 deletions src/main/java/carpet/settings/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,16 @@ public String description()
)
public static boolean debugNoteBlocks = false;

@Rule(
desc = "Let /teleport and /tp command supports teleporting to another dimension",
extra = {
"Let the command targets destination's dimension instead of command source's dimension",
"When enabled, the command behavior is the same as mc1.14+"
},
category = {CREATIVE}
)
public static boolean teleportCommandCrossDimensionSupport = false;

/*
@Rule(
desc = "If a beacon receives an NC update when a purpur block is adjacent, " +
Expand Down

0 comments on commit dd5444b

Please sign in to comment.