Skip to content

Commit

Permalink
Fix block entity archetype querying
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Jul 14, 2024
1 parent 2bd300b commit 994fb27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/spongepowered/common/SpongeCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.inject.Singleton;
import net.minecraft.SharedConstants;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -95,8 +96,12 @@ public static MinecraftServer server() {
return (MinecraftServer) Sponge.server();
}

public static RegistryAccess.Frozen vanillaRegistryAccess() {
return SpongeCommon.server().registryAccess();
}

public static <E> Registry<E> vanillaRegistry(ResourceKey<? extends Registry<? extends E>> key) {
return SpongeCommon.server().registryAccess().registryOrThrow(key);
return SpongeCommon.vanillaRegistryAccess().registryOrThrow(key);
}

public static ServerScheduler serverScheduler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ public String toString() {
if (this.cachedBlockEntity == null) {
final CompoundTag compound = this.compound.copy();
compound.putString(Constants.Item.BLOCK_ENTITY_ID, SpongeCommon.vanillaRegistry(Registries.BLOCK_ENTITY_TYPE).getKey((net.minecraft.world.level.block.entity.BlockEntityType<?>) this.type).toString());
//TODO fixme
//this.cachedBlockEntity = net.minecraft.world.level.block.entity.BlockEntity.loadStatic(new BlockPos(0, 0, 0), (net.minecraft.world.level.block.state.BlockState) this.blockState, compound);
this.cachedBlockEntity = net.minecraft.world.level.block.entity.BlockEntity.loadStatic(new BlockPos(0, 0, 0), (net.minecraft.world.level.block.state.BlockState) this.blockState, compound, SpongeCommon.vanillaRegistryAccess());
}
return Arrays.asList(this, (DataHolder) this.cachedBlockEntity);
}
Expand Down

0 comments on commit 994fb27

Please sign in to comment.