Finish fixing RTP

This commit is contained in:
Aria 2023-02-28 09:13:42 -07:00
parent 516f067fb9
commit a58cc55a5e
10 changed files with 89 additions and 59 deletions

View file

@ -46,7 +46,7 @@ public class HomesCommand {
for (Home string : homes.getList()) {
Style st = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.BOLD+ChatColor.DARK_GREEN+"Click here to go to this home")).withClickEvent(Clickable.command("/home "+string.homeName));
ChatHelpers.broadcastTo(player.getUUID(), new TextComponent(ChatColor.BOLD + ChatColor.MINECOIN_GOLD+"["+ChatColor.resetChat()+ChatColor.UNDERLINE+ChatColor.BOLD+ChatColor.DARK_GREEN+"HOME"+ChatColor.resetChat()+ChatColor.BOLD+ChatColor.MINECOIN_GOLD+"] "+ChatColor.resetChat()+ChatColor.YELLOW+string).setStyle(st), ctx.getSource().getServer());
ChatHelpers.broadcastTo(player.getUUID(), new TextComponent(ChatColor.BOLD + ChatColor.MINECOIN_GOLD+"["+ChatColor.resetChat()+ChatColor.UNDERLINE+ChatColor.BOLD+ChatColor.DARK_GREEN+"HOME"+ChatColor.resetChat()+ChatColor.BOLD+ChatColor.MINECOIN_GOLD+"] "+ChatColor.resetChat()+ChatColor.YELLOW+string.homeName).setStyle(st), ctx.getSource().getServer());
}
}catch(CommandSyntaxException ex)

View file

@ -2,16 +2,9 @@ package dev.zontreck.essentials.commands.teleport;
import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.essentials.AriasEssentials;
import dev.zontreck.essentials.Messages;
import dev.zontreck.essentials.util.RTPContainer;
import dev.zontreck.essentials.util.RandomPositionFactory;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
@ -44,7 +37,7 @@ public class RTPCommand {
}
final ServerPlayer pla = (ServerPlayer)source.getEntity();
final TeleportContainer cont = new TeleportContainer(pla, Vec3.ZERO, pla.getRotationVector(), source.getLevel());
//final TeleportContainer cont = new TeleportContainer(pla, Vec3.ZERO, pla.getRotationVector(), source.getLevel());
@ -52,37 +45,15 @@ public class RTPCommand {
@Override
public void run(){
// We can now execute the loop to search for a safe spot!
Vector3 v = new Vector3();
//Vector3 v = new Vector3();
// RTP is not designed to be safe really, but we at least want to check if where we are putting the player is air
Vec3 pos = pla.position();
boolean found_place= false;
RTPContainer container = RandomPositionFactory.beginRTPSearch(pla, pos, pla.getRotationVector(), pla.getLevel());
while(!container.complete)
{
if(!AriasEssentials.ALIVE)
{
container.aborted=true;
container.containingThread.interrupt();
return;
}
if(container.tries>30)
{
// abort!
return;
}
}
v = container.container.world_pos.Position;
ChatHelpers.broadcastTo(pla.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), pla.server);
// Apply the effect
TeleportActioner.ApplyTeleportEffect(pla);
cont.Position=v.asMinecraftVector();
TeleportActioner.PerformTeleport(cont);
//boolean found_place= false;
RandomPositionFactory.beginRTPSearch(pla, pos, pla.getRotationVector(), pla.getLevel());
return;
}
});

View file

@ -76,24 +76,8 @@ public class WarpCommand {
if(type==1){
try {
dest.Position = Vector3.ZERO;
RTPContainer cont = RandomPositionFactory.beginRTPSearch(p, Vec3.ZERO, Vec2.ZERO, f_dim);
while(!cont.complete)
{
if(!AriasEssentials.ALIVE)
{
cont.aborted=true;
cont.containingThread.interrupt();
return;
}
if(cont.tries>30)
{
return;
}
}
dest.Position = cont.container.world_pos.Position;
//RTPCommand.findPosition(source.getLevel(), false, p.getUUID());
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX+ChatColor.doColors(" !Dark_Green!Location found, warping!")), p.server);
RandomPositionFactory.beginRTPSearch(p, Vec3.ZERO, Vec2.ZERO, f_dim);
return;
} catch (Exception e) {
e.printStackTrace();
return;