This commit is contained in:
gnembon committed 2025-10-28 23:43:51 +01:00
1 parent b0ea03d1c3
commit 461e64d34c
22 files changed
+81 -125

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=false
# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=25w43a
minecraft_version=25w44a
loader_version=0.17.3
jsr305_version=3.0.2
fabric_version=0.134.0+1.21.9
@@ -1,23 +0,0 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.utils.SpawnOverrides;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.monster.Husk;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Husk.class)
public class Husk_templesMixin
{
@Redirect(method = "checkHuskSpawnRules", at = @At(value = "INVOKE", target="Lnet/minecraft/world/level/ServerLevelAccessor;canSeeSky(Lnet/minecraft/core/BlockPos;)Z"))
private static boolean isSkylightOrTempleVisible(ServerLevelAccessor serverWorldAccess, BlockPos pos)
{
return serverWorldAccess.canSeeSky(pos) ||
(CarpetSettings.huskSpawningInTemples && SpawnOverrides.isStructureAtPosition((ServerLevel)serverWorldAccess, BuiltinStructures.DESERT_PYRAMID, pos));
}
}
@@ -5,8 +5,8 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.gamerules.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -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() && livingEntity.level() instanceof ServerLevel serverLevel && CarpetSettings.cleanLogs && serverLevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
return livingEntity.hasCustomName() && livingEntity.level() instanceof ServerLevel serverLevel && CarpetSettings.cleanLogs && serverLevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES);
}
}
@@ -3,6 +3,7 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.LevelInterface;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.gamerules.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -14,7 +15,6 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
@Mixin(LivingEntity.class)
@@ -44,7 +44,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
int maxEntityCramming =-1;
if (CarpetSettings.maxEntityCollisions > 0)
{
maxEntityCramming = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
maxEntityCramming = serverLevel.getGameRules().get(GameRules.MAX_ENTITY_CRAMMING);
entities = ((LevelInterface) serverLevel).getOtherEntitiesLimited(
this,
this.getBoundingBox(),
@@ -57,7 +57,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
}
if (!entities.isEmpty()) {
if (maxEntityCramming < 0) maxEntityCramming = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
if (maxEntityCramming < 0) maxEntityCramming = serverLevel.getGameRules().get(GameRules.MAX_ENTITY_CRAMMING);
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
int candidates = 0;
@@ -0,0 +1,28 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.utils.SpawnOverrides;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Monster.class)
public class Monster_templesMixin
{
@Redirect(method = "checkSurfaceMonstersSpawnRules", at = @At(value = "INVOKE", target="Lnet/minecraft/world/level/ServerLevelAccessor;canSeeSky(Lnet/minecraft/core/BlockPos;)Z"))
private static boolean isSkylightOrTempleVisible(ServerLevelAccessor serverWorldAccess, BlockPos pos,
EntityType<? extends Mob> entityType, ServerLevelAccessor serverLevelAccessor, EntitySpawnReason entitySpawnReason, BlockPos blockPos, RandomSource randomSource)
{
return serverWorldAccess.canSeeSky(pos) ||
(CarpetSettings.huskSpawningInTemples && entityType == EntityType.HUSK && SpawnOverrides.isStructureAtPosition((ServerLevel)serverWorldAccess, BuiltinStructures.DESERT_PYRAMID, pos));
}
}
@@ -18,7 +18,8 @@ import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.gamerules.GameRule;
import net.minecraft.world.level.gamerules.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
@@ -66,8 +67,8 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerLevel) (Object)this, blockPos, bl2?1:0);
}
private Explosion.BlockInteraction getCMDestroyType(final GameRules.Key<GameRules.BooleanValue> rule) {
return getGameRules().getBoolean(rule) ? Explosion.BlockInteraction.DESTROY_WITH_DECAY : Explosion.BlockInteraction.DESTROY;
private Explosion.BlockInteraction getCMDestroyType(final GameRule<Boolean> rule) {
return getGameRules().get(rule) ? Explosion.BlockInteraction.DESTROY_WITH_DECAY : Explosion.BlockInteraction.DESTROY;
}
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
@@ -76,9 +77,9 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
if (EXPLOSION.isNeeded()) {
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
case NONE -> Explosion.BlockInteraction.KEEP;
case BLOCK -> this.getCMDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY);
case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getCMDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP;
case TNT -> this.getCMDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
case BLOCK -> this.getCMDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY);
case MOB -> this.getGameRules().get(GameRules.MOB_GRIEFING) ? this.getCMDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP;
case TNT -> this.getCMDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY);
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
};
@@ -10,7 +10,7 @@ import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.animal.horse.SkeletonHorse;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.gamerules.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -30,7 +30,7 @@ public class SummonCommand_lightningMixin
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;
boolean boolean_2 = world.getGameRules().get(GameRules.SPAWN_MOBS) && world.random.nextDouble() < (double)localDifficulty_1.getEffectiveDifficulty() * 0.01D;
if (boolean_2) {
SkeletonHorse skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world, EntitySpawnReason.EVENT);
skeletonHorseEntity_1.setTrap(true);
@@ -17,7 +17,7 @@ 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 net.minecraft.world.level.gamerules.GameRules;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
@@ -667,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.getLevel().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
if (int_1 > source.getLevel().getGameRules().get(GameRules.MAX_BLOCK_MODIFICATIONS))
{
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
return 1;
@@ -719,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.getLevel().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
if (int_1 > source.getLevel().getGameRules().get(GameRules.MAX_BLOCK_MODIFICATIONS))
{
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
return 1;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.annotation;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.api;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.argument;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.command;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.exception;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
+2 -7
View File
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.external;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.language;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -29,9 +29,9 @@ public class BiomeInfo
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
// todo add per postion query for environmental attributes as well
put("fog_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.FOG_COLOR));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().foliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
put("sky_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.SKY_COLOR));
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor()));
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().waterColor()));
put("water_fog_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.WATER_FOG_COLOR));
put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall()));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
@@ -15,7 +15,9 @@ import carpet.script.value.ValueConversions;
import com.sun.management.OperatingSystemMXBean;
import net.minecraft.SharedConstants;
import net.minecraft.server.packs.PackType;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.gamerules.GameRule;
import net.minecraft.world.level.gamerules.GameRuleTypeVisitor;
import net.minecraft.world.level.gamerules.GameRules;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.storage.LevelData;
import net.minecraft.world.level.storage.LevelResource;
@@ -166,12 +168,15 @@ public class SystemInfo
put("world_gamerules", c -> {
Map<Value, Value> rules = new HashMap<>();
GameRules gameRules = c.level().getGameRules();
gameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor()
gameRules.visitGameRuleTypes(new GameRuleTypeVisitor()
{
@Override
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type)
{
rules.put(StringValue.of(key.getId()), StringValue.of(gameRules.getRule(key).toString()));
public void visitBoolean(GameRule<Boolean> gameRule) {
rules.put(StringValue.of(gameRule.id()), BooleanValue.of(gameRules.get(gameRule)));
}
@Override
public void visitInteger(GameRule<Integer> gameRule) {
rules.put(StringValue.of(gameRule.id()), NumericValue.of(gameRules.get(gameRule)));
}
});
return MapValue.wrap(rules);
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.utils;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.utils.shapes;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
@@ -1,8 +1,3 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@NullMarked
package carpet.script.value;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
+1 -1
View File
@@ -81,7 +81,7 @@
"SaplingBlock_desertShrubsMixin",
"EntityMixin",
"Guardian_renewableSpongesMixin",
"Husk_templesMixin",
"Monster_templesMixin",
"ChunkGenerator_customMobSpawnsMixin",
"ServerChunkCacheMixin",
"NaturalSpawnerMixin",