This commit is contained in:
gnembon committed 2025-07-10 15:17:25 +02:00
1 parent 33c4ec28d9
commit 27e00903c7
6 files changed
+20 -46

No files matched your search

@@ -78,7 +78,6 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getCMDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; 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 TNT -> this.getCMDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
default -> throw new IncompatibleClassChangeError();
}; };
boolean cancelled = EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, new Vec3(x, y, z), g, bl, null, null, var10000); boolean cancelled = EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, new Vec3(x, y, z), g, bl, null, null, var10000);
@@ -16,6 +16,7 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandBuildContext;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.level.GameRules;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.IOException; import java.io.IOException;
@@ -665,7 +666,7 @@ public class ScriptCommand
BoundingBox area = BoundingBox.fromCorners(a, b); BoundingBox area = BoundingBox.fromCorners(a, b);
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan(); // X Y Z int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan(); // X Y Z
if (int_1 > Vanilla.MinecraftServer_getFillLimit(source.getServer()) ) if (int_1 > source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
{ {
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1); Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
return 1; return 1;
@@ -717,7 +718,7 @@ public class ScriptCommand
BoundingBox area = BoundingBox.fromCorners(a, b); BoundingBox area = BoundingBox.fromCorners(a, b);
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan(); int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan();
if (int_1 > Vanilla.MinecraftServer_getFillLimit(source.getServer())) if (int_1 > source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT))
{ {
Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1); Carpet.Messenger_message(source, "r too many blocks to evaluate: " + int_1);
return 1; return 1;
+1
View File
@@ -85,6 +85,7 @@ public class Carpet
return () -> CarpetProfiler.end_current_section(token); return () -> CarpetProfiler.end_current_section(token);
} }
// not needed in vanilla
public static void MinecraftServer_addScriptServer(MinecraftServer server, CarpetScriptServer scriptServer) public static void MinecraftServer_addScriptServer(MinecraftServer server, CarpetScriptServer scriptServer)
{ {
((MinecraftServerInterface) server).addScriptServer(scriptServer); ((MinecraftServerInterface) server).addScriptServer(scriptServer);
+10 -29
View File
@@ -1,23 +1,7 @@
package carpet.script.external; package carpet.script.external;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.fakes.BiomeInterface; import carpet.fakes.*;
import carpet.fakes.BlockPredicateInterface;
import carpet.fakes.BlockStateArgumentInterface;
import carpet.fakes.TicketsFetcherInterface;
import carpet.fakes.CommandDispatcherInterface;
import carpet.fakes.EntityInterface;
import carpet.fakes.InventoryBearerInterface;
import carpet.fakes.ItemEntityInterface;
import carpet.fakes.LivingEntityInterface;
import carpet.fakes.MinecraftServerInterface;
import carpet.fakes.MobEntityInterface;
import carpet.fakes.RandomStateVisitorAccessor;
import carpet.fakes.AbstractContainerMenuInterface;
import carpet.fakes.ServerPlayerInterface;
import carpet.fakes.ServerPlayerInteractionManagerInterface;
import carpet.fakes.ServerWorldInterface;
import carpet.fakes.SpawnHelperInnerInterface;
import carpet.mixins.Objective_scarpetMixin; import carpet.mixins.Objective_scarpetMixin;
import carpet.mixins.PoiRecord_scarpetMixin; import carpet.mixins.PoiRecord_scarpetMixin;
import carpet.mixins.Scoreboard_scarpetMixin; import carpet.mixins.Scoreboard_scarpetMixin;
@@ -46,7 +30,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.server.level.Ticket; import net.minecraft.server.level.Ticket;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.util.SortedArraySet;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@@ -56,10 +39,10 @@ import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.village.poi.PoiRecord; import net.minecraft.world.entity.ai.village.poi.PoiRecord;
import net.minecraft.world.entity.animal.horse.AbstractHorse; import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.DataSlot; import net.minecraft.world.inventory.DataSlot;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.NaturalSpawner; import net.minecraft.world.level.NaturalSpawner;
import net.minecraft.world.level.PotentialCalculator; import net.minecraft.world.level.PotentialCalculator;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
@@ -207,11 +190,6 @@ public class Vanilla
return ((ServerPlayerInterface) player).isInvalidEntityObject(); return ((ServerPlayerInterface) player).isInvalidEntityObject();
} }
public static String ServerPlayer_getLanguage(ServerPlayer player)
{
return player.clientInformation().language();
}
public static GoalSelector Mob_getAI(Mob mob, boolean target) public static GoalSelector Mob_getAI(Mob mob, boolean target)
{ {
return ((MobEntityInterface) mob).getAI(target); return ((MobEntityInterface) mob).getAI(target);
@@ -322,11 +300,6 @@ public class Vanilla
return CommandHelper.canUseCommand(player, CarpetSettings.commandScript); return CommandHelper.canUseCommand(player, CarpetSettings.commandScript);
} }
public static int MinecraftServer_getFillLimit(MinecraftServer server)
{
return server.getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT);
}
public static int PoiRecord_getFreeTickets(PoiRecord record) public static int PoiRecord_getFreeTickets(PoiRecord record)
{ {
return ((PoiRecord_scarpetMixin) record).getFreeTickets(); return ((PoiRecord_scarpetMixin) record).getFreeTickets();
@@ -337,6 +310,14 @@ public class Vanilla
((PoiRecord_scarpetMixin) record).callAcquireTicket(); ((PoiRecord_scarpetMixin) record).callAcquireTicket();
} }
public static double FoodData_getExhaustion(FoodData foodData) {
return ((FoodDataInterface)foodData).getCMExhaustionLevel();
}
public static void FoodData_setExhaustion(FoodData foodData, float exhaustion) {
((FoodDataInterface)foodData).setExhaustion(exhaustion);
}
public record BlockPredicatePayload(BlockState state, TagKey<Block> tagKey, Map<Value, Value> properties, CompoundTag tag) { public record BlockPredicatePayload(BlockState state, TagKey<Block> tagKey, Map<Value, Value> properties, CompoundTag tag) {
public static BlockPredicatePayload of(Predicate<BlockInWorld> blockPredicate) public static BlockPredicatePayload of(Predicate<BlockInWorld> blockPredicate)
{ {
@@ -1,5 +0,0 @@
package carpet.script.external;
public class VanillaClient
{
}
@@ -1,6 +1,5 @@
package carpet.script.value; package carpet.script.value;
import carpet.fakes.FoodDataInterface;
import carpet.script.external.Vanilla; import carpet.script.external.Vanilla;
import carpet.script.utils.Tracer; import carpet.script.utils.Tracer;
import carpet.script.CarpetContext; import carpet.script.CarpetContext;
@@ -27,11 +26,9 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.StringTag;
import net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket; import net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket;
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket; import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket;
import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket; import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket; import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@@ -53,8 +50,6 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.PositionMoveRotation;
import net.minecraft.world.entity.Relative;
import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeMap;
@@ -84,7 +79,6 @@ import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -553,11 +547,11 @@ public class EntityValue extends Value
put("swimming", (e, a) -> e.isSwimming() ? Value.TRUE : Value.FALSE); put("swimming", (e, a) -> e.isSwimming() ? Value.TRUE : Value.FALSE);
put("swinging", (e, a) -> e instanceof LivingEntity le ? BooleanValue.of(le.swinging) : Value.NULL); put("swinging", (e, a) -> e instanceof LivingEntity le ? BooleanValue.of(le.swinging) : Value.NULL);
put("air", (e, a) -> new NumericValue(e.getAirSupply())); put("air", (e, a) -> new NumericValue(e.getAirSupply()));
put("language", (e, a) -> !(e instanceof ServerPlayer p) ? NULL : StringValue.of(Vanilla.ServerPlayer_getLanguage(p))); put("language", (e, a) -> !(e instanceof ServerPlayer p) ? NULL : StringValue.of(p.clientInformation().language()));
put("persistence", (e, a) -> e instanceof Mob mob ? BooleanValue.of(mob.isPersistenceRequired()) : Value.NULL); put("persistence", (e, a) -> e instanceof Mob mob ? BooleanValue.of(mob.isPersistenceRequired()) : Value.NULL);
put("hunger", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getFoodLevel()) : Value.NULL); put("hunger", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getFoodLevel()) : Value.NULL);
put("saturation", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getSaturationLevel()) : Value.NULL); put("saturation", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getSaturationLevel()) : Value.NULL);
put("exhaustion", (e, a) -> e instanceof Player player ? new NumericValue(((FoodDataInterface)player.getFoodData()).getCMExhaustionLevel()) : Value.NULL); put("exhaustion", (e, a) -> e instanceof Player player ? new NumericValue(Vanilla.FoodData_getExhaustion(player.getFoodData())) : Value.NULL);
put("absorption", (e, a) -> e instanceof Player player ? new NumericValue(player.getAbsorptionAmount()) : Value.NULL); put("absorption", (e, a) -> e instanceof Player player ? new NumericValue(player.getAbsorptionAmount()) : Value.NULL);
put("xp", (e, a) -> e instanceof Player player ? new NumericValue(player.totalExperience) : Value.NULL); put("xp", (e, a) -> e instanceof Player player ? new NumericValue(player.totalExperience) : Value.NULL);
put("xp_level", (e, a) -> e instanceof Player player ? new NumericValue(player.experienceLevel) : Value.NULL); put("xp_level", (e, a) -> e instanceof Player player ? new NumericValue(player.experienceLevel) : Value.NULL);
@@ -1611,7 +1605,10 @@ public class EntityValue extends Value
put("exhaustion", (e, v) -> { put("exhaustion", (e, v) -> {
if (e instanceof Player p) if (e instanceof Player p)
{ {
((FoodDataInterface)p.getFoodData()).setExhaustion(NumericValue.asNumber(v).getFloat()); Vanilla.FoodData_setExhaustion(
p.getFoodData(),
NumericValue.asNumber(v, "exhaustion").getFloat()
);
} }
}); });