This commit is contained in:
gnembon committed 2025-10-11 19:56:14 +02:00
1 parent f5b7653cfb
commit b48a29b85c
19 files changed
+366 -370

No files matched your search

@@ -300,7 +300,9 @@ public class ShapeDispatcher
float lineWidth;
protected float r, g, b, a;
protected int color;
protected int argb;
protected float fr, fg, fb, fa;
protected int fargb;
protected int fillColor;
protected int duration = 0;
private long key;
@@ -310,6 +312,7 @@ public class ShapeDispatcher
protected boolean discreteX, discreteY, discreteZ;
protected ResourceKey<Level> shapeDimension;
protected boolean debug;
protected boolean seethrough;
protected ExpiringShape()
@@ -351,6 +354,11 @@ public class ShapeDispatcher
init(options, regs);
}
private int rgba2argb(int color) {
// return shift bits from alpha
return ((color & 0xFF) << 24) + (color >> 8 & 0xFFFFFF);
}
protected void init(Map<String, Value> options, RegistryAccess regs)
{
@@ -360,12 +368,14 @@ public class ShapeDispatcher
lineWidth = NumericValue.asNumber(options.getOrDefault("line", optional.get("line"))).getFloat();
fillColor = NumericValue.asNumber(options.getOrDefault("fill", optional.get("fill"))).getInt();
this.fargb = rgba2argb(fillColor);
this.fr = (fillColor >> 24 & 0xFF) / 255.0F;
this.fg = (fillColor >> 16 & 0xFF) / 255.0F;
this.fb = (fillColor >> 8 & 0xFF) / 255.0F;
this.fa = (fillColor & 0xFF) / 255.0F;
color = NumericValue.asNumber(options.getOrDefault("color", optional.get("color"))).getInt();
this.argb = rgba2argb(color);
this.r = (color >> 24 & 0xFF) / 255.0F;
this.g = (color >> 16 & 0xFF) / 255.0F;
this.b = (color >> 8 & 0xFF) / 255.0F;
@@ -377,6 +387,12 @@ public class ShapeDispatcher
debug = options.get("debug").getBoolean();
}
seethrough = false;
if (options.containsKey("debug"))
{
seethrough = options.get("seethrough").getBoolean();
}
key = 0;
followEntity = -1;
shapeDimension = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(options.get("dim").getString()));
@@ -464,6 +480,7 @@ public class ShapeDispatcher
hash ^= followEntity;
hash *= 1099511628211L;
hash ^= Boolean.hashCode(debug);
hash ^= Boolean.hashCode(seethrough);
hash *= 1099511628211L;
if (followEntity >= 0)
{
@@ -496,6 +513,7 @@ public class ShapeDispatcher
"follow", new NumericValue(-1),
"line", new NumericValue(2.0),
"debug", Value.FALSE,
"seethrough", Value.FALSE,
"fill", new NumericValue(0xffffff00),
"snap", new StringValue("xyz")
);
File diff suppressed because it is too large. Load diff
@@ -10,6 +10,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.PermissionSet;
import net.minecraft.util.Mth;
import net.minecraft.util.TaskChainer;
import net.minecraft.world.entity.Entity;
@@ -28,7 +29,7 @@ public class SnoopyCommandSource extends CommandSourceStack
private final CommandSource output;
private final Vec3 position;
private final ServerLevel world;
private final int level;
private final PermissionSet level;
private final String simpleName;
private final Component name;
private final MinecraftServer server;
@@ -47,8 +48,9 @@ public class SnoopyCommandSource extends CommandSourceStack
public SnoopyCommandSource(CommandSourceStack original, Component[] error, List<Component> chatOutput, OptionalLong[] returnValue)
{
super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), Vanilla.MinecraftServer_getRunPermissionLevel(original.getServer()),
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity(), false,
(b, i) -> returnValue[0] = OptionalLong.of(i), EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(original.getServer()));
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity()
//,false ,(b, i) -> returnValue[0] = OptionalLong.of(i), EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(original.getServer())
);
this.output = CommandSource.NULL;
this.position = original.getPosition();
this.world = original.getLevel();
@@ -89,13 +91,14 @@ public class SnoopyCommandSource extends CommandSourceStack
this.taskChainer = TaskChainer.immediate(player.level().getServer());
}
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, PermissionSet level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
Component[] error, List<Component> chatOutput
)
{
super(output, pos, rot, world, level,
simpleName, name, server, entity, false,
consumer, entityAnchor, context, chainer);
simpleName, name, server, entity
// , false, consumer, entityAnchor, context, chainer
);
this.output = output;
this.position = pos;
this.rotation = rot;
@@ -149,13 +152,13 @@ public class SnoopyCommandSource extends CommandSourceStack
//public ServerCommandSource withSilent() { return this; }
@Override
public CommandSourceStack withPermission(int level)
public CommandSourceStack withPermission(PermissionSet level)
{
return this;
}
@Override
public CommandSourceStack withMaximumPermission(int level)
public CommandSourceStack withMaximumPermission(PermissionSet level)
{
return this;
}