mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-08 21:14:41 -04:00
25w05a
This commit is contained in:
parent
9eb1c5c7a2
commit
2dd063df02
13 changed files with 67 additions and 49 deletions
fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome
fabric-data-attachment-api-v1/src
main/java/net/fabricmc/fabric
test/java/net/fabricmc/fabric/test/attachment
fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event
fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest
fabric-object-builder-api-v1/src
client/java/net/fabricmc/fabric/mixin/object/builder/client
testmod/java/net/fabricmc/fabric/test/object/builder
fabric-rendering-v1/src
client/java/net/fabricmc/fabric/mixin/client/rendering
testmodClient/java/net/fabricmc/fabric/test/rendering/client
fabric-transfer-api-v1/src/test/java/net/fabricmc/fabric/test/transfer/unittests
gradle.properties
|
@ -72,13 +72,15 @@
|
|||
[
|
||||
"minecraft:glow_lichen",
|
||||
"minecraft:patch_tall_grass_2",
|
||||
"minecraft:patch_bush",
|
||||
"minecraft:trees_plains",
|
||||
"minecraft:flower_plains",
|
||||
"minecraft:patch_grass_plain",
|
||||
"minecraft:brown_mushroom_normal",
|
||||
"minecraft:red_mushroom_normal",
|
||||
"minecraft:patch_pumpkin",
|
||||
"minecraft:patch_sugar_cane",
|
||||
"minecraft:patch_pumpkin"
|
||||
"minecraft:patch_firefly_bush_near_water"
|
||||
],
|
||||
[
|
||||
"minecraft:freeze_top_layer"
|
||||
|
|
|
@ -16,10 +16,15 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.attachment;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.Decoder;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Encoder;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.PersistentState;
|
||||
|
||||
|
@ -37,9 +42,22 @@ public class AttachmentPersistentState extends PersistentState {
|
|||
this.wasSerialized = worldTarget.fabric_hasPersistentAttachments();
|
||||
}
|
||||
|
||||
public static AttachmentPersistentState read(ServerWorld world, @Nullable NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
((AttachmentTargetImpl) world).fabric_readAttachmentsFromNbt(nbt, wrapperLookup);
|
||||
return new AttachmentPersistentState(world);
|
||||
// TODO 1.21.5 look at making this more idiomatic
|
||||
public static Codec<AttachmentPersistentState> codec(ServerWorld world) {
|
||||
return Codec.of(new Encoder<>() {
|
||||
@Override
|
||||
public <T> DataResult<T> encode(AttachmentPersistentState input, DynamicOps<T> ops, T prefix) {
|
||||
NbtCompound nbtCompound = new NbtCompound();
|
||||
((AttachmentTargetImpl) world).fabric_writeAttachmentsToNbt(nbtCompound, world.getRegistryManager());
|
||||
return DataResult.success((T) nbtCompound);
|
||||
}
|
||||
}, new Decoder<>() {
|
||||
@Override
|
||||
public <T> DataResult<Pair<AttachmentPersistentState, T>> decode(DynamicOps<T> ops, T input) {
|
||||
((AttachmentTargetImpl) world).fabric_readAttachmentsFromNbt((NbtCompound) ops.convertTo(NbtOps.INSTANCE, input), world.getRegistryManager());
|
||||
return DataResult.success(Pair.of(new AttachmentPersistentState(world), ops.empty()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,10 +65,4 @@ public class AttachmentPersistentState extends PersistentState {
|
|||
// Only write data if there are attachments, or if we previously wrote data.
|
||||
return wasSerialized || worldTarget.fabric_hasPersistentAttachments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
worldTarget.fabric_writeAttachmentsToNbt(nbt, wrapperLookup);
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.class_10741;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.MutableWorldProperties;
|
||||
import net.minecraft.world.PersistentState;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
|
@ -65,12 +65,13 @@ abstract class ServerWorldMixin extends World implements AttachmentTargetImpl {
|
|||
private void createAttachmentsPersistentState(CallbackInfo ci) {
|
||||
// Force persistent state creation
|
||||
ServerWorld world = (ServerWorld) (Object) this;
|
||||
var type = new PersistentState.Type<>(
|
||||
var type = new class_10741<>(
|
||||
AttachmentPersistentState.ID,
|
||||
() -> new AttachmentPersistentState(world),
|
||||
(nbt, wrapperLookup) -> AttachmentPersistentState.read(world, nbt, server.getRegistryManager()),
|
||||
AttachmentPersistentState.codec(world),
|
||||
null // Object builder API 12.1.0 and later makes this a no-op
|
||||
);
|
||||
world.getPersistentStateManager().getOrCreate(type, AttachmentPersistentState.ID);
|
||||
world.getPersistentStateManager().getOrCreate(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -248,16 +248,25 @@ public class CommonAttachmentTests {
|
|||
@Test
|
||||
void testWorldPersistentState() {
|
||||
// Trying to simulate actual saving and loading for the world is too hard
|
||||
DynamicRegistryManager drm = mockDRM();
|
||||
|
||||
ServerWorld world = mockAndDisableSync(ServerWorld.class);
|
||||
when(world.getRegistryManager()).thenReturn(drm);
|
||||
|
||||
AttachmentPersistentState state = new AttachmentPersistentState(world);
|
||||
assertFalse(world.hasAttached(PERSISTENT));
|
||||
assertFalse(state.isDirty());
|
||||
|
||||
int expected = 1;
|
||||
world.setAttached(PERSISTENT, expected);
|
||||
NbtCompound fakeSave = state.writeNbt(new NbtCompound(), mockDRM());
|
||||
assertTrue(state.isDirty());
|
||||
NbtCompound fakeSave = (NbtCompound) AttachmentPersistentState.codec(world).encodeStart(RegistryOps.of(NbtOps.INSTANCE, drm), state).getOrThrow();
|
||||
assertEquals("{\"fabric:attachments\":{\"example:persistent\":1}}", fakeSave.toString());
|
||||
|
||||
world = mockAndDisableSync(ServerWorld.class);
|
||||
AttachmentPersistentState.read(world, fakeSave, mockDRM());
|
||||
when(world.getRegistryManager()).thenReturn(drm);
|
||||
|
||||
AttachmentPersistentState.codec(world).decode(RegistryOps.of(NbtOps.INSTANCE, drm), fakeSave).getOrThrow();
|
||||
assertTrue(world.hasAttached(PERSISTENT));
|
||||
assertEquals(expected, world.getAttached(PERSISTENT));
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ abstract class LivingEntityMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "damage", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void afterDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir, float dealt, boolean blocked) {
|
||||
private void afterDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir, float dealt, float f, boolean blocked) {
|
||||
if (!isDead()) {
|
||||
ServerLivingEntityEvents.AFTER_DAMAGE.invoker().afterDamage((LivingEntity) (Object) this, source, dealt, amount, blocked);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.function.Consumer;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
|
@ -145,7 +144,7 @@ final class TestAnnotationLocator {
|
|||
|
||||
TestInstance testInstance(Registry<TestEnvironmentDefinition> testEnvironmentDefinitionRegistry) {
|
||||
return new FunctionTestInstance(
|
||||
Registries.TEST_FUNCTION.getEntry(identifier()).get(),
|
||||
RegistryKey.of(RegistryKeys.TEST_FUNCTION, identifier()),
|
||||
testData(testEnvironmentDefinitionRegistry)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.class_10721;
|
||||
import net.minecraft.client.render.TexturedRenderLayers;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.SpriteMapper;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.impl.object.builder.client.SignTypeTextureHelper;
|
||||
|
@ -36,13 +36,13 @@ abstract class TexturedRenderLayersMixin {
|
|||
SignTypeTextureHelper.shouldAddTextures = true;
|
||||
}
|
||||
|
||||
@Redirect(method = "createSignTextureId", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_10721;method_67274(Ljava/lang/String;)Lnet/minecraft/client/util/SpriteIdentifier;"))
|
||||
private static SpriteIdentifier redirectSignVanillaId(class_10721 instance, String name) {
|
||||
return instance.method_67273(Identifier.of(name));
|
||||
@Redirect(method = "createSignTextureId", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteMapper;mapVanilla(Ljava/lang/String;)Lnet/minecraft/client/util/SpriteIdentifier;"))
|
||||
private static SpriteIdentifier redirectSignVanillaId(SpriteMapper instance, String name) {
|
||||
return instance.map(Identifier.of(name));
|
||||
}
|
||||
|
||||
@Redirect(method = "createHangingSignTextureId", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_10721;method_67274(Ljava/lang/String;)Lnet/minecraft/client/util/SpriteIdentifier;"))
|
||||
private static SpriteIdentifier redirectHangingVanillaId(class_10721 instance, String name) {
|
||||
return instance.method_67273(Identifier.of(name));
|
||||
@Redirect(method = "createHangingSignTextureId", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteMapper;mapVanilla(Ljava/lang/String;)Lnet/minecraft/client/util/SpriteIdentifier;"))
|
||||
private static SpriteIdentifier redirectHangingVanillaId(SpriteMapper instance, String name) {
|
||||
return instance.map(Identifier.of(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ abstract class WoodTypeMixin {
|
|||
private static void onReturnRegister(WoodType type, CallbackInfoReturnable<WoodType> cir) {
|
||||
if (SignTypeTextureHelper.shouldAddTextures) {
|
||||
final Identifier identifier = Identifier.of(type.name());
|
||||
TexturedRenderLayers.SIGN_TYPE_TEXTURES.put(type, TexturedRenderLayers.field_56363.method_67273(identifier));
|
||||
TexturedRenderLayers.HANGING_SIGN_TYPE_TEXTURES.put(type, TexturedRenderLayers.field_56364.method_67273(identifier));
|
||||
TexturedRenderLayers.SIGN_TYPE_TEXTURES.put(type, TexturedRenderLayers.SIGN_SPRITE_MAPPER.map(identifier));
|
||||
TexturedRenderLayers.HANGING_SIGN_TYPE_TEXTURES.put(type, TexturedRenderLayers.HANGING_SIGN_SPRITE_MAPPER.map(identifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ package net.fabricmc.fabric.test.object.builder;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.class_10741;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.PersistentState;
|
||||
|
||||
|
@ -44,10 +46,13 @@ public class PersistentStateManagerTest implements ModInitializer {
|
|||
/**
|
||||
* We are testing that null can be passed as the dataFixType.
|
||||
*/
|
||||
private static final PersistentState.Type<TestState> TYPE = new Type<>(TestState::new, TestState::fromTag, null);
|
||||
private static final Codec<TestState> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.STRING.fieldOf("value").forGetter(TestState::getValue)
|
||||
).apply(instance, TestState::new));
|
||||
private static final class_10741<TestState> TYPE = new class_10741<>(ObjectBuilderTestConstants.id("test_state").toString().replace(":", "_"), TestState::new, CODEC, null);
|
||||
|
||||
public static TestState getOrCreate(ServerWorld world) {
|
||||
return world.getPersistentStateManager().getOrCreate(TestState.TYPE, ObjectBuilderTestConstants.id("test_state").toString().replace(":", "_"));
|
||||
return world.getPersistentStateManager().getOrCreate(TestState.TYPE);
|
||||
}
|
||||
|
||||
private String value = "";
|
||||
|
@ -67,15 +72,5 @@ public class PersistentStateManagerTest implements ModInitializer {
|
|||
this.value = value;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
nbt.putString("value", value);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
private static TestState fromTag(NbtCompound tag, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
return new TestState(tag.getString("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.minecraft.util.dynamic.Codecs;
|
|||
|
||||
@Mixin(AtlasSourceManager.class)
|
||||
public interface AtlasSourceManagerAccessor {
|
||||
@Accessor("field_56377")
|
||||
@Accessor("ID_MAPPER")
|
||||
static Codecs.IdMapper<Identifier, MapCodec<? extends AtlasSource>> getAtlasSourceCodecs() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class CustomAtlasSourcesTest implements ClientModInitializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends AtlasSource> method_67288() {
|
||||
public MapCodec<? extends AtlasSource> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.minecraft.class_10712;
|
||||
import net.minecraft.component.ComponentChanges;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.TooltipDisplayComponent;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.util.Unit;
|
||||
|
@ -48,7 +48,7 @@ class FluidVariantTests extends AbstractTransferApiTest {
|
|||
@Test
|
||||
public void testWithComponentChanges() {
|
||||
FluidVariant variant = FluidVariant.of(Fluids.WATER, ComponentChanges.builder()
|
||||
.add(DataComponentTypes.TOOLTIP_DISPLAY, class_10712.field_56318)
|
||||
.add(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplayComponent.DEFAULT)
|
||||
.build());
|
||||
|
||||
FluidVariant newVariant = variant.withComponentChanges(ComponentChanges.builder()
|
||||
|
|
|
@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M
|
|||
org.gradle.parallel=true
|
||||
|
||||
version=0.115.1
|
||||
minecraft_version=25w04a
|
||||
minecraft_version=25w05a
|
||||
yarn_version=+build.1
|
||||
loader_version=0.16.10
|
||||
installer_version=1.0.1
|
||||
|
|
Loading…
Add table
Reference in a new issue