diff --git a/gradle.properties b/gradle.properties index 3ff3b905..394b7899 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=25w19a + minecraft_version=25w20a loader_version=0.16.10 jsr305_version=3.0.2 fabric_version=0.119.5+1.21.5 diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index 7240fc8a..2d9c8174 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -39,7 +39,7 @@ public class PerimeterInfoCommand BlockPosArgument.getSpawnablePos(c, "center position"), null)). then(argument("mob", resource(commandBuildContext, Registries.ENTITY_TYPE)). - suggests(SuggestionProviders.SUMMONABLE_ENTITIES). + suggests(SuggestionProviders.cast(SuggestionProviders.SUMMONABLE_ENTITIES)). executes( (c) -> perimeterDiagnose( c.getSource(), BlockPosArgument.getSpawnablePos(c, "center position"), diff --git a/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java b/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java index a07fdd4d..d0c9f58f 100644 --- a/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java +++ b/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java @@ -1,20 +1,24 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.PermissionSource; import net.minecraft.server.commands.PerfCommand; +import net.minecraft.server.commands.PermissionCheck; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(PerfCommand.class) public class PerfCommand_permissionMixin { - @Inject(method = "method_37340", at = @At("HEAD"), cancellable = true, remap = false) - private static void canRun(CommandSourceStack source, CallbackInfoReturnable cir) + @Redirect(method = "register", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/commands/Commands;hasPermission(I)Lnet/minecraft/server/commands/PermissionCheck;" + )) + private static PermissionCheck canRun(int i) { - cir.setReturnValue(source.hasPermission(CarpetSettings.perfPermissionLevel)); + return Commands.hasPermission(CarpetSettings.perfPermissionLevel); } } diff --git a/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java b/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java index c8e13dc4..9dee70b4 100644 --- a/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java +++ b/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java @@ -25,9 +25,9 @@ public class SummonCommand_lightningMixin private static BlockPos addRiders(Entity entity) { // [CM] SummonNaturalLightning - if statement around - if (CarpetSettings.summonNaturalLightning && entity instanceof LightningBolt && !entity.getCommandSenderWorld().isClientSide) + if (CarpetSettings.summonNaturalLightning && entity instanceof LightningBolt && !entity.level().isClientSide) { - ServerLevel world = (ServerLevel) entity.getCommandSenderWorld(); + ServerLevel world = (ServerLevel) entity.level(); BlockPos at = entity.blockPosition(); DifficultyInstance localDifficulty_1 = world.getCurrentDifficultyAt(at); boolean boolean_2 = world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getEffectiveDifficulty() * 0.01D; diff --git a/src/main/java/carpet/mixins/Villager_aiMixin.java b/src/main/java/carpet/mixins/Villager_aiMixin.java index ea0a0b1e..2829f9ac 100644 --- a/src/main/java/carpet/mixins/Villager_aiMixin.java +++ b/src/main/java/carpet/mixins/Villager_aiMixin.java @@ -127,7 +127,7 @@ public abstract class Villager_aiMixin extends AbstractVillager if (bedPos == null || bedPos.dimension() != level().dimension()) // get Dimension { setUnhappy(); - ((ServerLevel) getCommandSenderWorld()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY() + getEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0); + ((ServerLevel) level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY() + getEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0); } else { @@ -142,7 +142,7 @@ public abstract class Villager_aiMixin extends AbstractVillager } else if (itemStack_1.getItem() instanceof BedItem) { - List list_1 = ((ServerLevel) getCommandSenderWorld()).getPoiManager().getInRange( + List list_1 = ((ServerLevel) level()).getPoiManager().getInRange( type -> type.is(PoiTypes.HOME), blockPosition(), 48, PoiManager.Occupancy.ANY).toList(); @@ -151,16 +151,16 @@ public abstract class Villager_aiMixin extends AbstractVillager Vec3 pv = Vec3.atCenterOf(poi.getPos()); if (!poi.hasSpace()) { - ((ServerLevel) getCommandSenderWorld()).sendParticles(ParticleTypes.HAPPY_VILLAGER, + ((ServerLevel) level()).sendParticles(ParticleTypes.HAPPY_VILLAGER, pv.x, pv.y+1.5, pv.z, 50, 0.1, 0.3, 0.1, 0.0); } else if (canReachHome((Villager)(Object)this, poi.getPos(), poi)) - ((ServerLevel) getCommandSenderWorld()).sendParticles(ParticleTypes.END_ROD, + ((ServerLevel) level()).sendParticles(ParticleTypes.END_ROD, pv.x, pv.y+1, pv.z, 50, 0.1, 0.3, 0.1, 0.0); else - ((ServerLevel) getCommandSenderWorld()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), + ((ServerLevel) level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), pv.x, pv.y+1, pv.z, 1, 0.1, 0.1, 0.1, 0.0); } @@ -186,7 +186,7 @@ public abstract class Villager_aiMixin extends AbstractVillager { if (MobAI.isTracking(this, MobAI.TrackingType.IRON_GOLEM_SPAWNING)) { - ((ServerLevel) getCommandSenderWorld()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY()+3, getZ(), 1, 0.1, 0.1, 0.1, 0.0); + ((ServerLevel) level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY()+3, getZ(), 1, 0.1, 0.1, 0.1, 0.0); } } diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index a4c29a99..78310667 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -162,7 +162,7 @@ public abstract class CommandArgument (c, p) -> StringValue.of(EntityAnchorArgument.getAnchor(c, p).name()), false ), new VanillaUnconfigurableArgument("entitytype", c -> ResourceArgument.resource(c, Registries.ENTITY_TYPE), - (c, p) -> ValueConversions.of(ResourceArgument.getSummonableEntityType(c, p).key()), SuggestionProviders.SUMMONABLE_ENTITIES + (c, p) -> ValueConversions.of(ResourceArgument.getSummonableEntityType(c, p).key()), SuggestionProviders.cast(SuggestionProviders.SUMMONABLE_ENTITIES) ), new VanillaUnconfigurableArgument("floatrange", RangeArgument::floatRange, (c, p) -> ValueConversions.of(c.getArgument(p, MinMaxBounds.Doubles.class)), true @@ -205,12 +205,8 @@ public abstract class CommandArgument new VanillaUnconfigurableArgument("recipe", Registries.RECIPE), new VanillaUnconfigurableArgument("advancement", Registries.ADVANCEMENT), - new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().reloadableRegistries().getKeys(Registries.LOOT_CONDITION_TYPE), builder) - ), - new VanillaUnconfigurableArgument("loottable", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), LootCommand.SUGGEST_LOOT_TABLE - ), + new VanillaUnconfigurableArgument("lootcondition", Registries.LOOT_CONDITION_TYPE), + new VanillaUnconfigurableArgument("loottable", Registries.LOOT_TABLE), new VanillaUnconfigurableArgument("attribute", Registries.ATTRIBUTE), new VanillaUnconfigurableArgument("boss", ResourceLocationArgument::id, @@ -233,7 +229,7 @@ public abstract class CommandArgument }, (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().registryAccess().lookupOrThrow(Registries.BIOME).keySet(), builder) ), new VanillaUnconfigurableArgument("sound", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_SOUNDS + (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), SuggestionProviders.cast(SuggestionProviders.AVAILABLE_SOUNDS) ), new VanillaUnconfigurableArgument("storekey", ResourceLocationArgument::id, (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getCommandStorage().keys(), builder) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index c910fe33..64e06dfb 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -573,7 +573,7 @@ public class EntityValue extends Value { return Value.NULL; } - return ValueConversions.fromPath((ServerLevel) e.getCommandSenderWorld(), path); + return ValueConversions.fromPath((ServerLevel) e.level(), path); } return Value.NULL; }); @@ -624,7 +624,7 @@ public class EntityValue extends Value { return StringValue.of(moddedType); } - MinecraftServer server = p.getCommandSenderWorld().getServer(); + MinecraftServer server = p.level().getServer(); if (server.isDedicatedServer()) { return new StringValue("multiplayer"); @@ -829,7 +829,7 @@ public class EntityValue extends Value case MISS: return Value.NULL; case BLOCK: - return new BlockValue((ServerLevel) e.getCommandSenderWorld(), ((BlockHitResult) hitres).getBlockPos()); + return new BlockValue((ServerLevel) e.level(), ((BlockHitResult) hitres).getBlockPos()); case ENTITY: return new EntityValue(((EntityHitResult) hitres).getEntity()); } @@ -927,7 +927,7 @@ public class EntityValue extends Value } else { - ((ServerLevel) e.getCommandSenderWorld()).getChunkSource().broadcastAndSend(e, ClientboundEntityPositionSyncPacket.of(e)); + ((ServerLevel) e.level()).getChunkSource().broadcastAndSend(e, ClientboundEntityPositionSyncPacket.of(e)); } } } @@ -1376,7 +1376,7 @@ public class EntityValue extends Value List params = lv.getItems(); Vector3Argument blockLocator = Vector3Argument.findIn(params, 0, false, false); BlockPos pos = BlockPos.containing(blockLocator.vec); - ResourceKey world = spe.getCommandSenderWorld().dimension(); + ResourceKey world = spe.level().dimension(); float angle = spe.getYHeadRot(); boolean forced = false; if (params.size() > blockLocator.offset) diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 23c7536e..f9622974 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -144,7 +144,7 @@ public class ValueConversions { if (dimensionValue instanceof EntityValue) { - return ((EntityValue) dimensionValue).getEntity().getCommandSenderWorld(); + return ((EntityValue) dimensionValue).getEntity().level(); } else if (dimensionValue instanceof BlockValue bv) { @@ -265,7 +265,7 @@ public class ValueConversions } if (v instanceof final BlockPos pos) { - return new BlockValue(null, (ServerLevel) e.getCommandSenderWorld(), pos); + return new BlockValue(null, (ServerLevel) e.level(), pos); } if (v instanceof final Number number) { @@ -277,7 +277,7 @@ public class ValueConversions } if (v instanceof final UUID uuid) { - return ofUUID((ServerLevel) e.getCommandSenderWorld(), uuid); + return ofUUID((ServerLevel) e.level(), uuid); } if (v instanceof final DamageSource source) { @@ -288,16 +288,16 @@ public class ValueConversions } if (v instanceof final Path path) { - return fromPath((ServerLevel) e.getCommandSenderWorld(), path); + return fromPath((ServerLevel) e.level(), path); } if (v instanceof final PositionTracker tracker) { - return new BlockValue(null, (ServerLevel) e.getCommandSenderWorld(), tracker.currentBlockPosition()); + return new BlockValue(null, (ServerLevel) e.level(), tracker.currentBlockPosition()); } if (v instanceof final WalkTarget target) { return ListValue.of( - new BlockValue(null, (ServerLevel) e.getCommandSenderWorld(), target.getTarget().currentBlockPosition()), + new BlockValue(null, (ServerLevel) e.level(), target.getTarget().currentBlockPosition()), new NumericValue(target.getSpeedModifier()), new NumericValue(target.getCloseEnoughDist()) ); diff --git a/src/main/java/carpet/utils/MobAI.java b/src/main/java/carpet/utils/MobAI.java index 5063b879..193b1565 100644 --- a/src/main/java/carpet/utils/MobAI.java +++ b/src/main/java/carpet/utils/MobAI.java @@ -30,7 +30,7 @@ public class MobAI public static boolean isTracking(Entity e, TrackingType type) { - if (e.getCommandSenderWorld().isClientSide()) + if (e.level().isClientSide()) return false; Set currentTrackers = aiTrackers.get(e.getType()); if (currentTrackers == null) diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index c36f17f6..439f505a 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -182,7 +182,7 @@ public class PerimeterDiagnostics { el.snapTo(pos.getX() + 0.5F, pos.getY(), pos.getZ()+0.5F, 0.0F, 0.0F); return el.checkSpawnObstruction(worldServer) && el.checkSpawnRules(worldServer, EntitySpawnReason.NATURAL) && - SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.getCommandSenderWorld(), EntitySpawnReason.NATURAL, el.blockPosition(), el.getCommandSenderWorld().random) && + SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.level(), EntitySpawnReason.NATURAL, el.blockPosition(), el.level().random) && worldServer.noCollision(el); // check collision rules once they stop fiddling with them after 1.14.1 } return false; diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 4c96755d..3c086e4f 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -382,7 +382,7 @@ public class SpawnReporter } if (entity instanceof Ocelot) { - for (Entity e: entity.getCommandSenderWorld().getEntities(entity, entity.getBoundingBox())) + for (Entity e: entity.level().getEntities(entity, entity.getBoundingBox())) { e.discard(); }