25w41a
This commit is contained in:
1 parent
f5b7653cfb
commit
b48a29b85c
19 files changed
+356
-360
No files matched your search
+3
-3
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=1.21.10
|
||||
loader_version=0.17.2
|
||||
minecraft_version=25w41a
|
||||
loader_version=0.17.3
|
||||
jsr305_version=3.0.2
|
||||
fabric_version=0.119.5+1.21.5
|
||||
fabric_version=0.134.0+1.21.9
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.4.186
|
||||
|
||||
@@ -12,12 +12,16 @@ import carpet.utils.Messenger;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.SemanticVersion;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerInterface;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.permissions.LevelBasedPermissionSet;
|
||||
import net.minecraft.server.permissions.PermissionCheck;
|
||||
import net.minecraft.server.permissions.PermissionSet;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -56,7 +60,7 @@ public class CarpetSettings
|
||||
public static final Logger LOG = LoggerFactory.getLogger("carpet");
|
||||
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
|
||||
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
|
||||
public static int runPermissionLevel = 2;
|
||||
public static PermissionSet runPermissionLevel = LevelBasedPermissionSet.GAMEMASTER;
|
||||
public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID;
|
||||
private static class LanguageValidator extends Validator<String> {
|
||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
||||
@@ -129,7 +133,7 @@ public class CarpetSettings
|
||||
|
||||
private static class CarpetPermissionLevel extends Validator<String> {
|
||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
||||
if (source == null || source.hasPermission(4))
|
||||
if (source == null || Commands.LEVEL_OWNERS.check(source.permissions()))
|
||||
return newValue;
|
||||
return null;
|
||||
}
|
||||
@@ -423,10 +427,32 @@ public class CarpetSettings
|
||||
@Rule(
|
||||
desc = "Required permission level for /perf command",
|
||||
options = {"2", "4"},
|
||||
category = CREATIVE
|
||||
category = CREATIVE,
|
||||
validate = PermissionValidator.class
|
||||
)
|
||||
public static int perfPermissionLevel = 4;
|
||||
|
||||
public static class PermissionValidator extends Validator<Integer> {
|
||||
@Override
|
||||
public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
|
||||
if (newValue == 2) {
|
||||
perfPermissionCheck = Commands.LEVEL_GAMEMASTERS;
|
||||
|
||||
} else if (newValue == 4) {
|
||||
perfPermissionCheck = Commands.LEVEL_OWNERS;
|
||||
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "You must have the permission level you are trying to set";
|
||||
}
|
||||
}
|
||||
public static PermissionCheck perfPermissionCheck = Commands.LEVEL_OWNERS;
|
||||
|
||||
|
||||
@Rule(desc = "Enables /log command to monitor events via chat and overlays", category = COMMAND)
|
||||
public static String commandLog = "true";
|
||||
|
||||
@@ -476,17 +502,21 @@ public class CarpetSettings
|
||||
|
||||
private static class ModulePermissionLevel extends Validator<String> {
|
||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
||||
int permissionLevel = switch (newValue) {
|
||||
case "false" -> 0;
|
||||
case "true", "ops" -> 2;
|
||||
case "0", "1", "2", "3", "4" -> Integer.parseInt(newValue);
|
||||
PermissionCheck permissionLevel = switch (newValue) {
|
||||
case "0", "false" -> Commands.LEVEL_ALL;
|
||||
case "1" -> Commands.LEVEL_MODERATORS;
|
||||
case "2", "true", "ops" -> Commands.LEVEL_GAMEMASTERS;
|
||||
case "3" -> Commands.LEVEL_ADMINS;
|
||||
case "4" -> Commands.LEVEL_OWNERS;
|
||||
default -> throw new IllegalArgumentException(); // already checked by previous validator
|
||||
};
|
||||
if (source != null && !source.hasPermission(permissionLevel))
|
||||
if (source != null && !permissionLevel.check(source.permissions()))
|
||||
return null;
|
||||
CarpetSettings.runPermissionLevel = permissionLevel;
|
||||
if (source != null)
|
||||
CarpetSettings.runPermissionLevel = LevelBasedPermissionSet.GAMEMASTER;
|
||||
if (source != null) {
|
||||
CommandHelper.notifyPlayersCommandsChanged(source.getServer());
|
||||
CarpetSettings.runPermissionLevel =source.permissions();
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ public class InfoCommand
|
||||
|
||||
private static int infoBlock(CommandSourceStack source, BlockPos pos, String grep)
|
||||
{
|
||||
if (!source.hasPermission(Commands.LEVEL_GAMEMASTERS)) {
|
||||
if (!Commands.LEVEL_GAMEMASTERS.check(source.permissions())) {
|
||||
//check id pos is loaded
|
||||
if (!source.getLevel().hasChunkAt(pos)) {
|
||||
Messenger.m(source, "r Chunk is not loaded");
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.GameModeArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.RotationArgument;
|
||||
@@ -98,13 +99,13 @@ public class PlayerCommand
|
||||
.then(literal("left").executes(manipulation(ap -> ap.setStrafing(1))))
|
||||
.then(literal("right").executes(manipulation(ap -> ap.setStrafing(-1))))
|
||||
).then(literal("spawn").executes(PlayerCommand::spawn)
|
||||
.then(literal("in").requires((player) -> player.hasPermission(2))
|
||||
.then(literal("in").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
|
||||
.then(argument("gamemode", GameModeArgument.gameMode())
|
||||
.executes(PlayerCommand::spawn)))
|
||||
.then(literal("at").then(argument("position", Vec3Argument.vec3()).executes(PlayerCommand::spawn)
|
||||
.then(literal("facing").then(argument("direction", RotationArgument.rotation()).executes(PlayerCommand::spawn)
|
||||
.then(literal("in").then(argument("dimension", DimensionArgument.dimension()).executes(PlayerCommand::spawn)
|
||||
.then(literal("in").requires((player) -> player.hasPermission(2))
|
||||
.then(literal("in").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
|
||||
.then(argument("gamemode", GameModeArgument.gameMode())
|
||||
.executes(PlayerCommand::spawn)
|
||||
)))
|
||||
@@ -230,7 +231,7 @@ public class PlayerCommand
|
||||
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is banned on this server");
|
||||
return true;
|
||||
}
|
||||
if (manager.isUsingWhitelist() && manager.isWhiteListed(profile) && !context.getSource().hasPermission(2))
|
||||
if (manager.isUsingWhitelist() && manager.isWhiteListed(profile) && !Commands.LEVEL_GAMEMASTERS.check(context.getSource().permissions()))
|
||||
{
|
||||
Messenger.m(context.getSource(), "r Whitelisted players can only be spawned by operators");
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class Guardian_renewableSpongesMixin extends Monster
|
||||
{
|
||||
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level());
|
||||
elderGuardian.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
elderGuardian.finalizeSpawn(serverWorld ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
elderGuardian.finalizeSpawn(serverWorld ,serverWorld.getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
elderGuardian.setNoAi(this.isNoAi());
|
||||
|
||||
if (this.hasCustomName())
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LevelRenderer_scarpetRenderMixin
|
||||
final float deltaPartialTick = deltaTracker.getGameTimeDeltaPartialTick(false);
|
||||
FramePass pass = frameGraphBuilder.addPass("scarpet_shapes");
|
||||
targets.main = pass.readsAndWrites(targets.main);
|
||||
pass.executes(() -> CarpetClient.shapes.render(null, levelRenderState, deltaPartialTick));
|
||||
pass.executes(() -> CarpetClient.shapes.render(renderBuffers, levelRenderState, matrix4f, deltaPartialTick));
|
||||
featureRenderDispatcher.renderAllFeatures();
|
||||
renderBuffers.bufferSource().endLastBatch();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ public abstract class LivingEntity_cleanLogsMixin extends Entity
|
||||
@Redirect(method = "die", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasCustomName()Z"))
|
||||
private boolean shouldLogDeaths(LivingEntity livingEntity)
|
||||
{
|
||||
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && livingEntity.level().getServer().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
return livingEntity.hasCustomName() && livingEntity.level() instanceof ServerLevel serverLevel && CarpetSettings.cleanLogs && serverLevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.PermissionSource;
|
||||
import net.minecraft.server.commands.PerfCommand;
|
||||
import net.minecraft.server.commands.PermissionCheck;
|
||||
import net.minecraft.server.permissions.PermissionCheck;
|
||||
import net.minecraft.server.permissions.PermissionProviderCheck;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -14,11 +14,11 @@ public class PerfCommand_permissionMixin
|
||||
{
|
||||
@Redirect(method = "register", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/commands/Commands;hasPermission(I)Lnet/minecraft/server/commands/PermissionCheck;"
|
||||
target = "Lnet/minecraft/commands/Commands;hasPermission(Lnet/minecraft/server/permissions/PermissionCheck;)Lnet/minecraft/server/permissions/PermissionProviderCheck;"
|
||||
))
|
||||
private static PermissionCheck<PermissionSource> canRun(int i)
|
||||
private static PermissionProviderCheck canRun(PermissionCheck permissionCheck)
|
||||
{
|
||||
return Commands.hasPermission(CarpetSettings.perfPermissionLevel);
|
||||
return Commands.hasPermission(CarpetSettings.perfPermissionCheck);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public abstract class Player_fakePlayersMixin
|
||||
* To make sure player attacks are able to knockback fake players
|
||||
*/
|
||||
@Redirect(
|
||||
method = "attack",
|
||||
method = "causeExtraKnockback",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "Lnet/minecraft/world/entity/Entity;hurtMarked:Z",
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -202,6 +203,17 @@ public class CarpetScriptHost extends ScriptHost
|
||||
return command;
|
||||
}
|
||||
|
||||
private static boolean sourceHasPermissionLevel(CommandSourceStack source, int level) {
|
||||
return switch (level) {
|
||||
case 0 -> Commands.LEVEL_ALL.check(source.permissions());
|
||||
case 1 -> Commands.LEVEL_MODERATORS.check(source.permissions());
|
||||
case 2 -> Commands.LEVEL_GAMEMASTERS.check(source.permissions());
|
||||
case 3 -> Commands.LEVEL_ADMINS.check(source.permissions());
|
||||
case 4 -> Commands.LEVEL_OWNERS.check(source.permissions());
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
public Predicate<CommandSourceStack> getCommandConfigPermissions() throws CommandSyntaxException
|
||||
{
|
||||
Value confValue = appConfig.get(StringValue.of("command_permission"));
|
||||
@@ -216,13 +228,13 @@ public class CarpetScriptHost extends ScriptHost
|
||||
{
|
||||
throw CommandArgument.error("Numeric permission level for custom commands should be between 1 and 4");
|
||||
}
|
||||
return s -> s.hasPermission(level);
|
||||
return s -> sourceHasPermissionLevel(s, level);
|
||||
}
|
||||
if (!(confValue instanceof final FunctionValue fun))
|
||||
{
|
||||
String perm = confValue.getString().toLowerCase(Locale.ROOT);
|
||||
return switch (perm) {
|
||||
case "ops" -> s -> s.hasPermission(2);
|
||||
case "ops" -> s -> sourceHasPermissionLevel(s, 2);
|
||||
case "server" -> s -> !(s.getEntity() instanceof ServerPlayer);
|
||||
case "players" -> s -> s.getEntity() instanceof ServerPlayer;
|
||||
case "all" -> s -> true;
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -225,7 +226,7 @@ public class ScriptCommand
|
||||
BlockPosArgument.getSpawnablePos(cc, "to"),
|
||||
StringArgumentType.getString(cc, "arguments")
|
||||
))))));
|
||||
LiteralArgumentBuilder<CommandSourceStack> i = literal("scan").requires((player) -> player.hasPermission(2)).
|
||||
LiteralArgumentBuilder<CommandSourceStack> i = literal("scan").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)).
|
||||
then(argument("origin", BlockPosArgument.blockPos()).
|
||||
then(argument("from", BlockPosArgument.blockPos()).
|
||||
then(argument("to", BlockPosArgument.blockPos()).
|
||||
@@ -238,7 +239,7 @@ public class ScriptCommand
|
||||
BlockPosArgument.getSpawnablePos(cc, "to"),
|
||||
StringArgumentType.getString(cc, "expr")
|
||||
))))));
|
||||
LiteralArgumentBuilder<CommandSourceStack> e = literal("fill").requires((player) -> player.hasPermission(2)).
|
||||
LiteralArgumentBuilder<CommandSourceStack> e = literal("fill").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)).
|
||||
then(argument("origin", BlockPosArgument.blockPos()).
|
||||
then(argument("from", BlockPosArgument.blockPos()).
|
||||
then(argument("to", BlockPosArgument.blockPos()).
|
||||
@@ -265,7 +266,7 @@ public class ScriptCommand
|
||||
BlockPredicateArgument.getBlockPredicate(cc, "filter"),
|
||||
"solid"
|
||||
)))))))));
|
||||
LiteralArgumentBuilder<CommandSourceStack> t = literal("outline").requires((player) -> player.hasPermission(2)).
|
||||
LiteralArgumentBuilder<CommandSourceStack> t = literal("outline").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)).
|
||||
then(argument("origin", BlockPosArgument.blockPos()).
|
||||
then(argument("from", BlockPosArgument.blockPos()).
|
||||
then(argument("to", BlockPosArgument.blockPos()).
|
||||
@@ -666,7 +667,7 @@ public class ScriptCommand
|
||||
BoundingBox area = BoundingBox.fromCorners(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan(); // X Y Z
|
||||
if (int_1 > source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
|
||||
if (int_1 > source.getLevel().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
|
||||
{
|
||||
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
|
||||
return 1;
|
||||
@@ -718,7 +719,7 @@ public class ScriptCommand
|
||||
BoundingBox area = BoundingBox.fromCorners(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan();
|
||||
if (int_1 > source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
|
||||
if (int_1 > source.getLevel().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
|
||||
{
|
||||
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
|
||||
return 1;
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.level.Ticket;
|
||||
import net.minecraft.server.permissions.PermissionSet;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -140,7 +141,7 @@ public class Vanilla
|
||||
ServerNetworkHandler.sendCustomCommand(player, "scShapes", data);
|
||||
}
|
||||
|
||||
public static int MinecraftServer_getRunPermissionLevel(MinecraftServer server)
|
||||
public static PermissionSet MinecraftServer_getRunPermissionLevel(MinecraftServer server)
|
||||
{
|
||||
return CarpetSettings.runPermissionLevel;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import carpet.script.utils.InputValidator;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -35,6 +36,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.permissions.LevelBasedPermissionSet;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.Mth;
|
||||
@@ -120,11 +122,11 @@ public class EntityValue extends Value
|
||||
EntitySelector entitySelector = selectorCache.get(selector);
|
||||
if (entitySelector != null)
|
||||
{
|
||||
return entitySelector.findEntities(source.withMaximumPermission(4));
|
||||
return entitySelector.findEntities(source.withMaximumPermission(LevelBasedPermissionSet.OWNER));
|
||||
}
|
||||
entitySelector = new EntitySelectorParser(new StringReader(selector), true).parse();
|
||||
selectorCache.put(selector, entitySelector);
|
||||
return entitySelector.findEntities(source.withMaximumPermission(4));
|
||||
return entitySelector.findEntities(source.withMaximumPermission(LevelBasedPermissionSet.OWNER));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
@@ -599,13 +601,21 @@ public class EntityValue extends Value
|
||||
put("permission_level", (e, a) -> {
|
||||
if (e instanceof ServerPlayer spe)
|
||||
{
|
||||
for (int i = 4; i >= 0; i--)
|
||||
if (Commands.LEVEL_OWNERS.check(spe.permissions()))
|
||||
{
|
||||
if (spe.hasPermissions(i))
|
||||
{
|
||||
return new NumericValue(i);
|
||||
return new NumericValue(4);
|
||||
}
|
||||
|
||||
if (Commands.LEVEL_ADMINS.check(spe.permissions()))
|
||||
{
|
||||
return new NumericValue(3);
|
||||
}
|
||||
if (Commands.LEVEL_GAMEMASTERS.check(spe.permissions()))
|
||||
{
|
||||
return new NumericValue(2);
|
||||
}
|
||||
if (Commands.LEVEL_MODERATORS.check(spe.permissions()))
|
||||
{
|
||||
return new NumericValue(1);
|
||||
}
|
||||
return new NumericValue(0);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.permissions.PermissionSet;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
@@ -200,7 +201,7 @@ public class ScreenValue extends Value
|
||||
this.screenHandler = null;
|
||||
return false;
|
||||
}
|
||||
int runPermissionLevel = Vanilla.MinecraftServer_getRunPermissionLevel(player.level().getServer());
|
||||
PermissionSet runPermissionLevel = Vanilla.MinecraftServer_getRunPermissionLevel(player.level().getServer());
|
||||
CommandSourceStack source = player.createCommandSourceStack().withPermission(runPermissionLevel);
|
||||
CarpetScriptHost executingHost = appHost.retrieveForExecution(source, player);
|
||||
try
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.utils;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.TickTask;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -48,8 +49,12 @@ public final class CommandHelper {
|
||||
{
|
||||
case "true" -> true;
|
||||
case "false" -> false;
|
||||
case "ops" -> source.hasPermission(2); // typical for other cheaty commands
|
||||
case "0", "1", "2", "3", "4" -> source.hasPermission(Integer.parseInt(commandLevelString));
|
||||
case "ops" -> Commands.LEVEL_GAMEMASTERS.check(source.permissions()); // typical for other cheaty commands
|
||||
case "0" -> Commands.LEVEL_ALL.check(source.permissions());
|
||||
case "1" -> Commands.LEVEL_MODERATORS.check(source.permissions());
|
||||
case "2" -> Commands.LEVEL_GAMEMASTERS.check(source.permissions());
|
||||
case "3" -> Commands.LEVEL_ADMINS.check(source.permissions());
|
||||
case "4" -> Commands.LEVEL_OWNERS.check(source.permissions());
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ accessible class net/minecraft/world/level/border/WorldBorder$StaticBorderExtent
|
||||
accessible class net/minecraft/server/MinecraftServer$ReloadableResources
|
||||
accessible class net/minecraft/world/level/biome/Biome$ClimateSettings
|
||||
accessible class net/minecraft/world/level/block/entity/SculkSensorBlockEntity$VibrationUser
|
||||
#accessible class net/minecraft/commands/CommandSourceStack
|
||||
|
||||
#TODO fields and methods should be fetched via interfaces unless there is a good reason not to
|
||||
#accessible method net/minecraft/commands/CommandSourceStack <init> (Lnet/minecraft/commands/CommandSource;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec2;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/server/permissions/PermissionSet;Ljava/lang/String;Lnet/minecraft/network/chat/Component;Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/world/entity/Entity;BLnet/minecraft/commands/CommandResultCallback;Lnet/minecraft/commands/arguments/EntityAnchorArgument$Anchor;Lnet/minecraft/commands/CommandSigningContext;Lnet/minecraft/util/TaskChainer;)V
|
||||
accessible method net/minecraft/world/level/border/WorldBorder getListeners ()Ljava/util/List;
|
||||
accessible method net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator calculateTargetStrength (Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)I
|
||||
|
||||
|
||||
Reference in new issue
Block a user