This commit is contained in:
gnembon committed 2025-05-13 23:20:31 +02:00
1 parent 74e8a8d2ec
commit 52cf8c027a
11 files changed
+38 -38

No files matched your search

+1 -1
View File
@@ -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
@@ -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"),
@@ -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<Boolean> cir)
@Redirect(method = "register", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/commands/Commands;hasPermission(I)Lnet/minecraft/server/commands/PermissionCheck;"
))
private static PermissionCheck<PermissionSource> canRun(int i)
{
cir.setReturnValue(source.hasPermission(CarpetSettings.perfPermissionLevel));
return Commands.hasPermission(CarpetSettings.perfPermissionLevel);
}
}
@@ -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;
@@ -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<PoiRecord> list_1 = ((ServerLevel) getCommandSenderWorld()).getPoiManager().getInRange(
List<PoiRecord> 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);
}
}
@@ -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)
@@ -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<Value> params = lv.getItems();
Vector3Argument blockLocator = Vector3Argument.findIn(params, 0, false, false);
BlockPos pos = BlockPos.containing(blockLocator.vec);
ResourceKey<Level> world = spe.getCommandSenderWorld().dimension();
ResourceKey<Level> world = spe.level().dimension();
float angle = spe.getYHeadRot();
boolean forced = false;
if (params.size() > blockLocator.offset)
@@ -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())
);
+1 -1
View File
@@ -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<TrackingType> currentTrackers = aiTrackers.get(e.getType());
if (currentTrackers == null)
@@ -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;
@@ -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();
}