Skip to content

Commit

Permalink
Update to 25w03a (#4383)
Browse files Browse the repository at this point in the history
* Update to 25w03a

* Bump version
  • Loading branch information
modmuss50 authored Jan 15, 2025
1 parent 3f161dd commit c327076
Show file tree
Hide file tree
Showing 52 changed files with 404 additions and 785 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,12 @@ subprojects {
testmodImplementation sourceSets.main.output

// Make all modules depend on the gametest api (and thus res loader) to try and promote its usage.
if (project.name != "fabric-gametest-api-v1") {
testmodImplementation project(path: ':fabric-gametest-api-v1', configuration: 'namedElements')
testmodClientImplementation project(":fabric-gametest-api-v1").sourceSets.client.output
testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements')
testmodClientImplementation project(":fabric-resource-loader-v0").sourceSets.client.output
}
// if (project.name != "fabric-gametest-api-v1") {
// testmodImplementation project(path: ':fabric-gametest-api-v1', configuration: 'namedElements')
// testmodClientImplementation project(":fabric-gametest-api-v1").sourceSets.client.output
// testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements')
// testmodClientImplementation project(":fabric-resource-loader-v0").sourceSets.client.output
// }

// Make all testmods run with registry-sync-v0 as it is required to register new objects.
if (project.name != "fabric-registry-sync-v0") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@

import org.spongepowered.asm.mixin.MixinEnvironment;

import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;

public class FabricApiBaseGameTest {
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
//@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE) TODO 1.21.5 tests
public void auditMixins(TestContext context) {
MixinEnvironment.getCurrentEnvironment().audit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ default void setMusic(@NotNull Pool<MusicSound> sound) {
* @see BiomeEffects.Builder#music(MusicSound)
*/
default void setMusic(@NotNull MusicSound sound) {
setMusic(Pool.method_66214(sound));
setMusic(Pool.of(sound));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import net.minecraft.entity.SpawnGroup;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.collection.Present;
import net.minecraft.util.collection.Weighted;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.dimension.DimensionOptions;
Expand Down Expand Up @@ -148,7 +148,7 @@ public static Predicate<BiomeSelectionContext> spawnsOneOf(Set<EntityType<?>> en
SpawnSettings spawnSettings = context.getBiome().getSpawnSettings();

for (SpawnGroup spawnGroup : SpawnGroup.values()) {
for (Present<SpawnSettings.SpawnEntry> spawnEntry : spawnSettings.getSpawnEntries(spawnGroup).getEntries()) {
for (Weighted<SpawnSettings.SpawnEntry> spawnEntry : spawnSettings.getSpawnEntries(spawnGroup).getEntries()) {
if (entityTypes.contains(spawnEntry.value().type())) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import net.minecraft.sound.MusicSound;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.collection.Pool;
import net.minecraft.util.collection.Present;
import net.minecraft.util.collection.Weighted;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.BiomeParticleConfig;
Expand Down Expand Up @@ -341,7 +341,7 @@ private static <T> RegistryEntry.Reference<T> getEntry(Registry<T> registry, Reg

private class SpawnSettingsContextImpl implements SpawnSettingsContext {
private final SpawnSettings spawnSettings = biome.getSpawnSettings();
private final EnumMap<SpawnGroup, List<Present<SpawnSettings.SpawnEntry>>> fabricSpawners = new EnumMap<>(SpawnGroup.class);
private final EnumMap<SpawnGroup, List<Weighted<SpawnSettings.SpawnEntry>>> fabricSpawners = new EnumMap<>(SpawnGroup.class);

SpawnSettingsContextImpl() {
unfreezeSpawners();
Expand Down Expand Up @@ -374,7 +374,7 @@ public void freeze() {
private void freezeSpawners() {
Map<SpawnGroup, Pool<SpawnSettings.SpawnEntry>> spawners = new HashMap<>(spawnSettings.spawners);

for (Map.Entry<SpawnGroup, List<Present<SpawnSettings.SpawnEntry>>> entry : fabricSpawners.entrySet()) {
for (Map.Entry<SpawnGroup, List<Weighted<SpawnSettings.SpawnEntry>>> entry : fabricSpawners.entrySet()) {
if (entry.getValue().isEmpty()) {
spawners.put(entry.getKey(), Pool.empty());
} else {
Expand All @@ -399,7 +399,7 @@ public void addSpawn(SpawnGroup spawnGroup, SpawnSettings.SpawnEntry spawnEntry,
Objects.requireNonNull(spawnGroup);
Objects.requireNonNull(spawnEntry);

fabricSpawners.get(spawnGroup).add(new Present<>(spawnEntry, weight));
fabricSpawners.get(spawnGroup).add(new Weighted<>(spawnEntry, weight));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;
import net.minecraft.util.math.BlockPos;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;

public class EntitySelectorGameTest {
private void spawn(TestContext context, float health) {
MobEntity entity = context.spawnMob(EntityType.CREEPER, BlockPos.ORIGIN);
entity.setAiDisabled(true);
entity.setHealth(health);
}

@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
// @GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE) TODO 1.21.5 tests
public void testEntitySelector(TestContext context) {
BlockPos absolute = context.getAbsolutePos(BlockPos.ORIGIN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import net.minecraft.item.ItemConvertible;
import net.minecraft.loot.LootTable;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerProfession;

import net.fabricmc.fabric.impl.content.registry.VillagerInteractionRegistriesImpl;
Expand Down Expand Up @@ -77,26 +75,18 @@ public static void registerFood(ItemConvertible item, int foodValue) {
}
}

/**
* @deprecated Use {@link #registerGiftLootTable(VillagerProfession, RegistryKey)} instead.
*/
@Deprecated
public static void registerGiftLootTable(VillagerProfession profession, Identifier lootTable) {
registerGiftLootTable(profession, RegistryKey.of(RegistryKeys.LOOT_TABLE, lootTable));
}

/**
* Registers a hero of the village gifts loot table to a profession.
* @param profession the profession to modify
* @param lootTable the loot table to associate with the profession
*/
public static void registerGiftLootTable(VillagerProfession profession, RegistryKey<LootTable> lootTable) {
public static void registerGiftLootTable(RegistryKey<VillagerProfession> profession, RegistryKey<LootTable> lootTable) {
Objects.requireNonNull(profession, "Profession cannot be null!");
Objects.requireNonNull(lootTable, "Loot table identifier cannot be null!");
RegistryKey<LootTable> oldValue = GiveGiftsToHeroTaskAccessor.fabric_getGifts().put(profession, lootTable);

if (oldValue != null) {
LOGGER.info("Overriding previous gift loot table of {} profession, was: {}, now: {}", profession.id(), oldValue, lootTable);
LOGGER.info("Overriding previous gift loot table of {} profession, was: {}, now: {}", profession.getValue(), oldValue, lootTable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Mixin(GiveGiftsToHeroTask.class)
public interface GiveGiftsToHeroTaskAccessor {
@Accessor("GIFTS")
static Map<VillagerProfession, RegistryKey<LootTable>> fabric_getGifts() {
static Map<RegistryKey<VillagerProfession>, RegistryKey<LootTable>> fabric_getGifts() {
throw new AssertionError("Untransformed @Accessor");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,8 @@

package net.fabricmc.fabric.test.content.registry;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ComposterBlock;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.block.entity.BrewingStandBlockEntity;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.GameMode;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;

public class ContentRegistryGameTest {
/* TODO 1.21.5 tests
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testCompostingChanceRegistry(TestContext context) {
BlockPos pos = new BlockPos(0, 1, 0);
Expand Down Expand Up @@ -244,4 +220,6 @@ public void testBrewingDirt(TestContext context) {
context.complete();
});
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
package net.fabricmc.fabric.test.content.registry;

import net.minecraft.block.Blocks;
import net.minecraft.test.GameTest;
import net.minecraft.test.GameTestException;
import net.minecraft.test.TestContext;
import net.minecraft.text.Text;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;

public class FlammableTest {
/**
* Regression test for <a href="https://github.com/FabricMC/fabric/issues/2108">FlammableBlockRegistry ignoring tags on first load</a>.
*/
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
// @GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE) TODO 1.21.5 tests
public void testFlammableTag(TestContext context) {
if (FlammableBlockRegistry.getDefaultInstance().get(Blocks.SAND).getBurnChance() != 4) {
throw new GameTestException("Expected blocks in the sand tag to be flammable!");
context.method_66943(Text.literal("Expected blocks in the sand tag to be flammable!"));
}

context.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,15 @@

package net.fabricmc.fabric.test.attachment.gametest;

import java.util.List;
import java.util.Objects;
import java.util.function.IntSupplier;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.DrownedEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.test.GameTest;
import net.minecraft.test.GameTestException;
import net.minecraft.test.TestContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;

import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry;
import net.fabricmc.fabric.api.attachment.v1.AttachmentType;
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.fabricmc.fabric.test.attachment.AttachmentTestMod;
import net.fabricmc.fabric.test.attachment.mixin.ZombieEntityAccessor;

public class AttachmentCopyTests implements FabricGameTest {
public class AttachmentCopyTests {
// using a lambda type because serialization shouldn't play a role in this
public static AttachmentType<IntSupplier> DUMMY = AttachmentRegistry.create(
Identifier.of(AttachmentTestMod.MOD_ID, "dummy")
Expand All @@ -51,6 +34,7 @@ public class AttachmentCopyTests implements FabricGameTest {
AttachmentRegistry.Builder::copyOnDeath
);

/* TODO 1.21.5 tests
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testCrossWorldTeleport(TestContext context) {
MinecraftServer server = context.getWorld().getServer();
Expand Down Expand Up @@ -107,4 +91,6 @@ public void testMobConversion(TestContext context) {
converted.discard();
context.complete();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,10 @@
import com.mojang.logging.LogUtils;
import org.slf4j.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.test.GameTest;
import net.minecraft.test.GameTestException;
import net.minecraft.test.TestContext;
import net.minecraft.util.math.BlockPos;

import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget;
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.fabricmc.fabric.test.attachment.AttachmentTestMod;
import net.fabricmc.fabric.test.attachment.mixin.BlockEntityTypeAccessor;

public class BlockEntityTests implements FabricGameTest {
public class BlockEntityTests {
private static final Logger LOGGER = LogUtils.getLogger();

/* TODO 1.21.5 tests
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testBlockEntitySync(TestContext context) {
BlockPos pos = BlockPos.ORIGIN.up();
Expand Down Expand Up @@ -84,4 +66,6 @@ public void testBlockEntitySync(TestContext context) {
context.complete();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator createAxisRotatedBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/data/BlockStateSupplier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/client/data/TexturedModel$Factory;Lnet/minecraft/client/data/TexturedModel$Factory;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerCreakingHeart (Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator method_66528 (Lnet/minecraft/client/data/TexturedModel$Factory;Lnet/minecraft/block/Block;Ljava/lang/String;)Lnet/minecraft/util/Identifier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator createCreakingHeartModel (Lnet/minecraft/client/data/TexturedModel$Factory;Lnet/minecraft/block/Block;Ljava/lang/String;)Lnet/minecraft/util/Identifier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator createSubModel (Lnet/minecraft/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/Model;Ljava/util/function/Function;)Lnet/minecraft/util/Identifier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator createPressurePlateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/data/BlockStateSupplier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator createSlabBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/data/BlockStateSupplier;
Expand Down Expand Up @@ -221,9 +221,9 @@ transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator uploadParticleModel (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/util/Identifier;
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerBuiltin (Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerWoolAndCarpet (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator method_66529 (Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerLeafLitter (Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerFlowerbed (Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator method_66526 (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/IntProperty;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerSegmentedBlock (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/IntProperty;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerRandomHorizontalRotations (Lnet/minecraft/client/data/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerSouthDefaultHorizontalFacing (Lnet/minecraft/client/data/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/client/data/BlockStateModelGenerator registerGlassAndPane (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onInitialize() {
});
// If a chest is attacked and the player holds a lava bucket, delete it!
AttackBlockCallback.EVENT.register((player, world, hand, pos, side) -> {
if (!player.isSpectator() && world.canPlayerModifyAt(player, pos)) {
if (!player.isSpectator() && world.canEntityModifyAt(player, pos)) {
if (world.getBlockState(pos).isOf(Blocks.CHEST)) {
if (player.getStackInHand(hand).isOf(Items.LAVA_BUCKET)) {
world.setBlockState(pos, Blocks.AIR.getDefaultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,11 @@

package net.fabricmc.fabric.test.event.interaction;

import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;

import net.fabricmc.fabric.api.entity.FakePlayer;
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;

public class FakePlayerTests {
/**
* Try placing a sign with a fake player.
*/
/* TODO 1.21.5 tests
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testFakePlayerPlaceSign(TestContext context) {
// This is for Fabric internal testing only, if you copy this to your mod you're on your own...
Expand All @@ -63,9 +46,12 @@ public void testFakePlayerPlaceSign(TestContext context) {
context.complete();
}
*/

/**
* Try breaking a beehive with a fake player (see {@code BeehiveBlockMixin}).
*/
/* TODO 1.21.5 tests
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testFakePlayerBreakBeehive(TestContext context) {
BlockPos basePos = new BlockPos(0, 1, 0);
Expand All @@ -81,4 +67,6 @@ public void testFakePlayerBreakBeehive(TestContext context) {
context.expectBlock(Blocks.AIR, basePos);
context.complete();
}
*/
}
Loading

0 comments on commit c327076

Please sign in to comment.