Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

@@ -1,32 +1,31 @@
package carpet.utils;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.text.BaseText;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
public class DistanceCalculator
{
public static final HashMap<String, Vec3d> START_POINT_STORAGE = new HashMap<>();
public static final HashMap<String, Vec3> START_POINT_STORAGE = new HashMap<>();
public static boolean hasStartingPoint(ServerCommandSource source)
public static boolean hasStartingPoint(CommandSourceStack source)
{
return START_POINT_STORAGE.containsKey(source.getName());
return START_POINT_STORAGE.containsKey(source.getTextName());
}
public static List<BaseText> findDistanceBetweenTwoPoints(Vec3d pos1, Vec3d pos2)
public static List<BaseComponent> findDistanceBetweenTwoPoints(Vec3 pos1, Vec3 pos2)
{
double dx = MathHelper.abs((float)pos1.x-(float)pos2.x);
double dy = MathHelper.abs((float)pos1.y-(float)pos2.y);
double dz = MathHelper.abs((float)pos1.z-(float)pos2.z);
double dx = Mth.abs((float)pos1.x-(float)pos2.x);
double dy = Mth.abs((float)pos1.y-(float)pos2.y);
double dz = Mth.abs((float)pos1.z-(float)pos2.z);
double manhattan = dx+dy+dz;
double spherical = Math.sqrt(dx*dx + dy*dy + dz*dz);
double cylindrical = Math.sqrt(dx*dx + dz*dz);
List<BaseText> res = new ArrayList<>();
List<BaseComponent> res = new ArrayList<>();
res.add(Messenger.c("w Distance between ",
Messenger.tp("c",pos1),"w and ",
Messenger.tp("c",pos2),"w :"));
@@ -36,29 +35,29 @@ public class DistanceCalculator
return res;
}
public static int distance(ServerCommandSource source, Vec3d pos1, Vec3d pos2)
public static int distance(CommandSourceStack source, Vec3 pos1, Vec3 pos2)
{
Messenger.send(source, findDistanceBetweenTwoPoints(pos1, pos2));
return 1;
}
public static int setStart(ServerCommandSource source, Vec3d pos)
public static int setStart(CommandSourceStack source, Vec3 pos)
{
START_POINT_STORAGE.put(source.getName(), pos);
START_POINT_STORAGE.put(source.getTextName(), pos);
Messenger.m(source,"gi Initial point set to: ", Messenger.tp("g",pos));
return 1;
}
public static int setEnd(ServerCommandSource source, Vec3d pos)
public static int setEnd(CommandSourceStack source, Vec3 pos)
{
if ( !hasStartingPoint(source) )
{
START_POINT_STORAGE.put(source.getName(), pos);
Messenger.m(source,"gi There was no initial point for "+source.getName());
START_POINT_STORAGE.put(source.getTextName(), pos);
Messenger.m(source,"gi There was no initial point for "+source.getTextName());
Messenger.m(source,"gi Initial point set to: ", Messenger.tp("g",pos));
return 0;
}
Messenger.send(source, findDistanceBetweenTwoPoints( START_POINT_STORAGE.get(source.getName()), pos));
Messenger.send(source, findDistanceBetweenTwoPoints( START_POINT_STORAGE.get(source.getTextName()), pos));
return 1;
}
}