fix: 修复fabric同步错误wt
This commit is contained in:
parent
af3e313fde
commit
418e85394c
|
|
@ -17,6 +17,7 @@ dependencies {
|
|||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||
implementation project(":common")
|
||||
testImplementation "net.fabricmc:fabric-loader-junit:${fabric_loader_version}"
|
||||
}
|
||||
|
||||
loom {
|
||||
|
|
@ -38,7 +39,7 @@ loom {
|
|||
setConfigName("Fabric Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("run")
|
||||
|
||||
programArgs "--username", "R3944Realms"
|
||||
def args = [
|
||||
"-Dlib39.modid=${mod_id}".toString(),
|
||||
"-Dlib39.output=${generatedOutput}".toString(),
|
||||
|
|
@ -58,6 +59,7 @@ loom {
|
|||
|
||||
server {
|
||||
server()
|
||||
serverWithGui()
|
||||
setConfigName("Fabric Server")
|
||||
ideConfigGenerated(true)
|
||||
runDir("run")
|
||||
|
|
@ -72,8 +74,12 @@ loom {
|
|||
]
|
||||
vmArgs.addAll(args)
|
||||
}
|
||||
gameTest {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar', Jar) {
|
||||
dependsOn classes
|
||||
dependsOn project(':common').tasks.named('sourcesJar') // 显式依赖common的source
|
||||
|
|
@ -197,6 +203,9 @@ publishing {
|
|||
|
||||
}
|
||||
}
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
tasks.named('generateMetadataFileForMavenJavaPublication') {
|
||||
dependsOn tasks.named('remapJavadocJar')
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public record SyncNBTLookupDataEntityS2CPacket(int entityId, ResourceLocation id
|
|||
} else Lib39.LOGGER.debug("Unhandled sync data: {}", packet.data);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package top.r3944realms.lib39.core.sync;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public interface IEntityApiLookUpImplExtend<A, C> {
|
||||
A lib39$findWithoutCheck(Entity entity, C context);
|
||||
}
|
||||
|
|
@ -23,10 +23,11 @@ public class SyncData2LookupManager extends SyncData2Manager<SyncData2LookupMana
|
|||
* @param manager the manager
|
||||
* @param apiLookup the EntityApiLookup instance
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public TypedSyncEntry(ISyncManager<Entity, T> manager, @Nullable EntityApiLookup<T, Void> apiLookup) {
|
||||
super(manager, key -> {
|
||||
if (apiLookup != null) {
|
||||
T data = apiLookup.find(key, null);
|
||||
T data = ((IEntityApiLookUpImplExtend<T, Void>) apiLookup).lib39$findWithoutCheck(key, null);
|
||||
return Optional.ofNullable(data);
|
||||
}
|
||||
return Optional.empty();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public abstract class SyncLookupProvider<T extends NBTEntitySyncData> implements
|
|||
}
|
||||
T defaultLookup = createEmptyLookup(entity);
|
||||
ILib39SyncDataHolder.getHolder(entity).loadSyncData(defaultLookup);
|
||||
objectISyncDataISyncManager.getSyncMap().put(entity.getUUID(), defaultLookup);
|
||||
return defaultLookup;
|
||||
}
|
||||
).orElse(createEmptyLookup(entity));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package top.r3944realms.lib39.mixin;
|
||||
|
||||
import net.fabricmc.fabric.api.lookup.v1.custom.ApiProviderMap;
|
||||
import net.fabricmc.fabric.api.lookup.v1.entity.EntityApiLookup;
|
||||
import net.fabricmc.fabric.impl.lookup.entity.EntityApiLookupImpl;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import top.r3944realms.lib39.core.sync.IEntityApiLookUpImplExtend;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@Mixin(value = EntityApiLookupImpl.class, remap = false)
|
||||
public class MixinApiLookUpImpl<A, C> implements IEntityApiLookUpImplExtend<A, C> {
|
||||
@Shadow @Final private ApiProviderMap<EntityType<?>, EntityApiLookup.EntityApiProvider<A, C>> providerMap;
|
||||
|
||||
@Shadow @Final private List<EntityApiLookup.EntityApiProvider<A, C>> fallbackProviders;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public A lib39$findWithoutCheck(Entity entity, C context) {
|
||||
Objects.requireNonNull(entity, "Entity may not be null.");
|
||||
EntityApiLookup.EntityApiProvider<A, C> provider = providerMap.get(entity.getType());
|
||||
|
||||
if (provider != null) {
|
||||
A instance = provider.find(entity, context);
|
||||
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
for (EntityApiLookup.EntityApiProvider<A, C> fallback : fallbackProviders) {
|
||||
A instance = fallback.find(entity, context);
|
||||
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
"refmap": "${mod_id}.fabric.refmap.json",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"MixinApiLookUpImpl",
|
||||
"MixinEntity",
|
||||
"callback.MixinAnvilMenu",
|
||||
"callback.MixinDedicateServer"
|
||||
|
|
|
|||
|
|
@ -58,14 +58,6 @@ legacyForge {
|
|||
}
|
||||
server {
|
||||
server()
|
||||
programArguments.addAll(
|
||||
'--mod', project.mod_id,
|
||||
'--all',
|
||||
'--existing', forgeResources,
|
||||
'--existing', commonResources,
|
||||
'--existing', forgeBuildResources,
|
||||
'--existing', commonBuildResources
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +194,9 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// 处理资源
|
||||
processResources {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user