26.1-snap-6
This commit is contained in:
1 parent
b1aa6844d1
commit
22c788bf58
13 files changed
+68
-60
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=26.1-snapshot-5
|
||||
minecraft_version=26.1-snapshot-6
|
||||
loader_version=0.18.4
|
||||
loom_version=1.14-SNAPSHOT
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.entity.ai.memory.MemorySlot;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BrainInterface {
|
||||
Map<MemoryModuleType<?>, MemorySlot<?>> getMemoriesCM();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
|
||||
public interface ServerWorldInterface {
|
||||
ServerLevelData getWorldPropertiesCM();
|
||||
LevelEntityGetter<Entity> getEntityLookupCMPublic();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BrainInterface;
|
||||
import net.minecraft.world.entity.ai.Brain;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.entity.ai.memory.MemorySlot;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(Brain.class)
|
||||
public class Brain_scarpetMixin implements BrainInterface {
|
||||
@Shadow @Final
|
||||
private Map<MemoryModuleType<?>, MemorySlot<?>> memories;
|
||||
|
||||
@Override
|
||||
public Map<MemoryModuleType<?>, MemorySlot<?>> getMemoriesCM() {
|
||||
return memories;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import carpet.fakes.SimpleEntityLookupInterface;
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
@@ -37,14 +36,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION;
|
||||
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
||||
import static carpet.script.CarpetEventServer.Event.CHUNK_UNLOADED;
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevel_scarpetMixin extends Level implements ServerWorldInterface
|
||||
public abstract class ServerLevel_scarpetMixin extends Level
|
||||
{
|
||||
|
||||
@Shadow public abstract GameRules getGameRules();
|
||||
@@ -97,21 +94,4 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
|
||||
CHUNK_UNLOADED.onChunkEvent(level, levelChunk.getPos(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private ServerLevelData serverLevelData;
|
||||
@Shadow @Final private PersistentEntitySectionManager<Entity> entityManager;
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public ServerLevelData getWorldPropertiesCM(){
|
||||
return serverLevelData;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntityLookupCMPublic() {
|
||||
return entityManager.getEntityGetter();
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,14 @@ public abstract class Villager_aiMixin extends AbstractVillager
|
||||
if (MobAI.isTracking(this, MobAI.TrackingType.IRON_GOLEM_SPAWNING))
|
||||
{
|
||||
long time;
|
||||
Optional<? extends ExpirableValue<?>> last_seen = this.brain.getMemories().get(MemoryModuleType.GOLEM_DETECTED_RECENTLY);
|
||||
Optional<Boolean> last_seen = this.brain.getMemory(MemoryModuleType.GOLEM_DETECTED_RECENTLY);
|
||||
if (!last_seen.isPresent())
|
||||
{
|
||||
time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
time = last_seen.get().getTimeToLive();
|
||||
time = this.brain.getTimeUntilExpiry(MemoryModuleType.GOLEM_DETECTED_RECENTLY);
|
||||
}
|
||||
boolean recentlySeen = time > 0;
|
||||
Optional<Long> optional_11 = this.brain.getMemory(MemoryModuleType.LAST_SLEPT);
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerScoreboard;
|
||||
import net.minecraft.server.bossevents.CustomBossEvent;
|
||||
import net.minecraft.server.bossevents.CustomBossEvents;
|
||||
@@ -539,7 +540,8 @@ public class Scoreboards
|
||||
|
||||
expression.addContextFunction("bossbar", -1, (c, t, lv) ->
|
||||
{
|
||||
CustomBossEvents bossBarManager = ((CarpetContext) c).server().getCustomBossEvents();
|
||||
MinecraftServer server = ((CarpetContext) c).server();
|
||||
CustomBossEvents bossBarManager = server.getCustomBossEvents();
|
||||
if (lv.size() > 3)
|
||||
{
|
||||
throw new InternalExpressionException("'bossbar' accepts max three arguments");
|
||||
@@ -547,7 +549,7 @@ public class Scoreboards
|
||||
|
||||
if (lv.isEmpty())
|
||||
{
|
||||
return ListValue.wrap(bossBarManager.getEvents().stream().map(CustomBossEvent::getTextId).map(Identifier::toString).map(StringValue::of));
|
||||
return ListValue.wrap(bossBarManager.getEvents().stream().map(CustomBossEvent::customId).map(Identifier::toString).map(StringValue::of));
|
||||
}
|
||||
|
||||
String id = lv.get(0).getString();
|
||||
@@ -559,7 +561,7 @@ public class Scoreboards
|
||||
{
|
||||
return Value.FALSE;
|
||||
}
|
||||
return StringValue.of(bossBarManager.create(identifier, Component.literal(id)).getTextId().toString());
|
||||
return StringValue.of(bossBarManager.create(server.overworld().getRandom(), identifier, Component.literal(id)).customId().toString());
|
||||
}
|
||||
|
||||
String property = lv.get(1).getString();
|
||||
@@ -591,7 +593,7 @@ public class Scoreboards
|
||||
case "max" -> {
|
||||
if (propertyValue == null)
|
||||
{
|
||||
return NumericValue.of(bossBar.getMax());
|
||||
return NumericValue.of(bossBar.max());
|
||||
}
|
||||
if (!(propertyValue instanceof final NumericValue number))
|
||||
{
|
||||
@@ -616,7 +618,7 @@ public class Scoreboards
|
||||
if (propertyValue instanceof final ListValue list)
|
||||
{
|
||||
list.getItems().forEach(v -> {
|
||||
ServerPlayer player = EntityValue.getPlayerByValue(((CarpetContext) c).server(), propertyValue);
|
||||
ServerPlayer player = EntityValue.getPlayerByValue(server, propertyValue);
|
||||
if (player != null)
|
||||
{
|
||||
bossBar.addPlayer(player);
|
||||
@@ -624,7 +626,7 @@ public class Scoreboards
|
||||
});
|
||||
return Value.TRUE;
|
||||
}
|
||||
ServerPlayer player = EntityValue.getPlayerByValue(((CarpetContext) c).server(), propertyValue);
|
||||
ServerPlayer player = EntityValue.getPlayerByValue(server, propertyValue);
|
||||
if (player != null)
|
||||
{
|
||||
bossBar.addPlayer(player);
|
||||
@@ -641,7 +643,7 @@ public class Scoreboards
|
||||
{
|
||||
bossBar.removeAllPlayers();
|
||||
list.getItems().forEach(v -> {
|
||||
ServerPlayer p = EntityValue.getPlayerByValue(((CarpetContext) c).server(), v);
|
||||
ServerPlayer p = EntityValue.getPlayerByValue(server, v);
|
||||
if (p != null)
|
||||
{
|
||||
bossBar.addPlayer(p);
|
||||
@@ -649,7 +651,7 @@ public class Scoreboards
|
||||
});
|
||||
return Value.TRUE;
|
||||
}
|
||||
ServerPlayer p = EntityValue.getPlayerByValue(((CarpetContext) c).server(), propertyValue);
|
||||
ServerPlayer p = EntityValue.getPlayerByValue(server, propertyValue);
|
||||
bossBar.removeAllPlayers();
|
||||
if (p != null)
|
||||
{
|
||||
@@ -674,7 +676,7 @@ public class Scoreboards
|
||||
case "value" -> {
|
||||
if (propertyValue == null)
|
||||
{
|
||||
return NumericValue.of(bossBar.getValue());
|
||||
return NumericValue.of(bossBar.value());
|
||||
}
|
||||
if (!(propertyValue instanceof final NumericValue number))
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ import carpet.script.value.ValueConversions;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -66,6 +67,7 @@ import net.minecraft.world.level.levelgen.NoiseRouter;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.saveddata.WeatherData;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -436,6 +438,7 @@ public class WorldAccess
|
||||
|
||||
expression.addContextFunction("weather", -1, (c, t, lv) -> {
|
||||
ServerLevel world = ((CarpetContext) c).level();
|
||||
MinecraftServer server = world.getServer();
|
||||
|
||||
if (lv.isEmpty())//cos it can thunder when raining or when clear.
|
||||
{
|
||||
@@ -443,7 +446,7 @@ public class WorldAccess
|
||||
}
|
||||
|
||||
Value weather = lv.get(0);
|
||||
ServerLevelData worldProperties = Vanilla.ServerLevel_getWorldProperties(world);
|
||||
WeatherData worldProperties = server.getWeatherData();
|
||||
if (lv.size() == 1)
|
||||
{
|
||||
return new NumericValue(switch (weather.getString().toLowerCase(Locale.ROOT))
|
||||
@@ -459,9 +462,9 @@ public class WorldAccess
|
||||
int ticks = NumericValue.asNumber(lv.get(1), "tick_time in 'weather'").getInt();
|
||||
switch (weather.getString().toLowerCase(Locale.ROOT))
|
||||
{
|
||||
case "clear" -> world.setWeatherParameters(ticks, 0, false, false);
|
||||
case "rain" -> world.setWeatherParameters(0, ticks, true, false);
|
||||
case "thunder" -> world.setWeatherParameters(
|
||||
case "clear" -> server.setWeatherParameters(ticks, 0, false, false);
|
||||
case "rain" -> server.setWeatherParameters(0, ticks, true, false);
|
||||
case "thunder" -> server.setWeatherParameters(
|
||||
0,
|
||||
ticks,//this is used to set thunder time, idk why...
|
||||
true,
|
||||
|
||||
+7
-5
@@ -35,8 +35,11 @@ import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.Brain;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.entity.ai.memory.MemorySlot;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiRecord;
|
||||
import net.minecraft.world.entity.animal.equine.AbstractHorse;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -101,11 +104,6 @@ public class Vanilla
|
||||
return ((Scoreboard_scarpetMixin) scoreboard).getObjectivesByCriterion();
|
||||
}
|
||||
|
||||
public static ServerLevelData ServerLevel_getWorldProperties(ServerLevel world)
|
||||
{
|
||||
return ((ServerWorldInterface) world).getWorldPropertiesCM();
|
||||
}
|
||||
|
||||
public static Long2ObjectOpenHashMap<List<Ticket>> ChunkTicketManager_getTicketsByPosition(DistanceManager ticketManager)
|
||||
{
|
||||
return ((TicketsFetcherInterface) ticketManager).getTicketsByPosition();
|
||||
@@ -166,6 +164,10 @@ public class Vanilla
|
||||
return MapValue.wrap(ret);
|
||||
}
|
||||
|
||||
public static Map<MemoryModuleType<?>, MemorySlot<?>> Brain_getMemories(Brain brain) {
|
||||
return ((BrainInterface) brain).getMemoriesCM();
|
||||
}
|
||||
|
||||
public static LevelStorageSource.LevelStorageAccess MinecraftServer_storageSource(MinecraftServer server)
|
||||
{
|
||||
return ((MinecraftServerInterface) server).getCMSession();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SystemInfo
|
||||
|
||||
put("world_time", c -> new NumericValue(c.level().getGameTime()));
|
||||
|
||||
put("game_difficulty", c -> StringValue.of(c.server().getWorldData().getDifficulty().getKey()));
|
||||
put("game_difficulty", c -> StringValue.of(c.server().getWorldData().getDifficulty().getSerializedName()));
|
||||
put("game_hardcore", c -> BooleanValue.of(c.server().getWorldData().isHardcore()));
|
||||
put("game_storage_format", c -> StringValue.of(c.server().getWorldData().getStorageVersionName(c.server().getWorldData().getVersion())));
|
||||
put("game_default_gamemode", c -> StringValue.of(c.server().getDefaultGameType().getName()));
|
||||
|
||||
@@ -60,6 +60,7 @@ import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal;
|
||||
import net.minecraft.world.entity.ai.memory.ExpirableValue;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.entity.ai.memory.MemorySlot;
|
||||
import net.minecraft.world.entity.animal.golem.IronGolem;
|
||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -589,15 +590,13 @@ public class EntityValue extends Value
|
||||
if (e instanceof LivingEntity livingEntity)
|
||||
{
|
||||
Brain<?> brain = livingEntity.getBrain();
|
||||
Map<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memories = brain.getMemories();
|
||||
Optional<? extends ExpirableValue<?>> optmemory = memories.get(moduleType);
|
||||
if (optmemory == null || !optmemory.isPresent())
|
||||
Map<MemoryModuleType<?>, MemorySlot<?>> memories = Vanilla.Brain_getMemories(brain);
|
||||
MemorySlot<?> optmemory = memories.get(moduleType);
|
||||
if (optmemory == null)
|
||||
{
|
||||
return Value.NULL;
|
||||
}
|
||||
ExpirableValue<?> memory = optmemory.get();
|
||||
return ValueConversions.fromTimedMemory(e, memory.getTimeToLive(), memory.getValue());
|
||||
}
|
||||
return ValueConversions.fromTimedMemory(e, optmemory.timeToLive(), optmemory.value()); }
|
||||
return Value.NULL;
|
||||
});
|
||||
put("gamemode_id", (e, a) -> e instanceof ServerPlayer sp ? new NumericValue(sp.gameMode.getGameModeForPlayer().getId()) : Value.NULL);
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
"CommandDispatcher_scarpetCommandsMixin",
|
||||
"FoodData_scarpetMixin",
|
||||
"CommandSourceStack_scarpetMixin",
|
||||
"Brain_scarpetMixin",
|
||||
|
||||
"BlockInput_scarpetMixin",
|
||||
"BlockPredicate_scarpetMixin",
|
||||
|
||||
Reference in new issue
Block a user