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}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||||
implementation project(":common")
|
implementation project(":common")
|
||||||
|
testImplementation "net.fabricmc:fabric-loader-junit:${fabric_loader_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
|
@ -38,7 +39,7 @@ loom {
|
||||||
setConfigName("Fabric Client")
|
setConfigName("Fabric Client")
|
||||||
ideConfigGenerated(true)
|
ideConfigGenerated(true)
|
||||||
runDir("run")
|
runDir("run")
|
||||||
|
programArgs "--username", "R3944Realms"
|
||||||
def args = [
|
def args = [
|
||||||
"-Dlib39.modid=${mod_id}".toString(),
|
"-Dlib39.modid=${mod_id}".toString(),
|
||||||
"-Dlib39.output=${generatedOutput}".toString(),
|
"-Dlib39.output=${generatedOutput}".toString(),
|
||||||
|
|
@ -58,6 +59,7 @@ loom {
|
||||||
|
|
||||||
server {
|
server {
|
||||||
server()
|
server()
|
||||||
|
serverWithGui()
|
||||||
setConfigName("Fabric Server")
|
setConfigName("Fabric Server")
|
||||||
ideConfigGenerated(true)
|
ideConfigGenerated(true)
|
||||||
runDir("run")
|
runDir("run")
|
||||||
|
|
@ -72,8 +74,12 @@ loom {
|
||||||
]
|
]
|
||||||
vmArgs.addAll(args)
|
vmArgs.addAll(args)
|
||||||
}
|
}
|
||||||
|
gameTest {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('sourcesJar', Jar) {
|
tasks.named('sourcesJar', Jar) {
|
||||||
dependsOn classes
|
dependsOn classes
|
||||||
dependsOn project(':common').tasks.named('sourcesJar') // 显式依赖common的source
|
dependsOn project(':common').tasks.named('sourcesJar') // 显式依赖common的source
|
||||||
|
|
@ -197,6 +203,9 @@ publishing {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
tasks.named('generateMetadataFileForMavenJavaPublication') {
|
tasks.named('generateMetadataFileForMavenJavaPublication') {
|
||||||
dependsOn tasks.named('remapJavadocJar')
|
dependsOn tasks.named('remapJavadocJar')
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ public record SyncNBTLookupDataEntityS2CPacket(int entityId, ResourceLocation id
|
||||||
} else Lib39.LOGGER.debug("Unhandled sync data: {}", packet.data);
|
} 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 manager the manager
|
||||||
* @param apiLookup the EntityApiLookup instance
|
* @param apiLookup the EntityApiLookup instance
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public TypedSyncEntry(ISyncManager<Entity, T> manager, @Nullable EntityApiLookup<T, Void> apiLookup) {
|
public TypedSyncEntry(ISyncManager<Entity, T> manager, @Nullable EntityApiLookup<T, Void> apiLookup) {
|
||||||
super(manager, key -> {
|
super(manager, key -> {
|
||||||
if (apiLookup != null) {
|
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.ofNullable(data);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public abstract class SyncLookupProvider<T extends NBTEntitySyncData> implements
|
||||||
}
|
}
|
||||||
T defaultLookup = createEmptyLookup(entity);
|
T defaultLookup = createEmptyLookup(entity);
|
||||||
ILib39SyncDataHolder.getHolder(entity).loadSyncData(defaultLookup);
|
ILib39SyncDataHolder.getHolder(entity).loadSyncData(defaultLookup);
|
||||||
|
objectISyncDataISyncManager.getSyncMap().put(entity.getUUID(), defaultLookup);
|
||||||
return defaultLookup;
|
return defaultLookup;
|
||||||
}
|
}
|
||||||
).orElse(createEmptyLookup(entity));
|
).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",
|
"refmap": "${mod_id}.fabric.refmap.json",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"MixinApiLookUpImpl",
|
||||||
"MixinEntity",
|
"MixinEntity",
|
||||||
"callback.MixinAnvilMenu",
|
"callback.MixinAnvilMenu",
|
||||||
"callback.MixinDedicateServer"
|
"callback.MixinDedicateServer"
|
||||||
|
|
|
||||||
|
|
@ -58,14 +58,6 @@ legacyForge {
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
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 {
|
processResources {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user