-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0bb4ef
commit d1308de
Showing
13 changed files
with
141 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/DataMapModifications.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.fabricmc.fabric.impl.content.registry; | ||
|
||
import net.fabricmc.fabric.api.registry.VillagerInteractionRegistries; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.neoforged.neoforge.registries.datamaps.DataMapType; | ||
import net.neoforged.neoforge.registries.datamaps.builtin.Compostable; | ||
import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; | ||
import net.neoforged.neoforge.registries.datamaps.builtin.RaidHeroGift; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
public class DataMapModifications { | ||
@SuppressWarnings("unchecked") | ||
public static <A, T> void modify(Registry<T> registry, DataMapType<T, A> type, ResourceKey<T> key, CallbackInfoReturnable<A> cir) { | ||
if (type == NeoForgeDataMaps.COMPOSTABLES) { | ||
registry.getHolder(key).ifPresent(holder -> { | ||
var fromCustom = CompostingChanceRegistryImpl.CUSTOM.get(holder.value()); | ||
if (fromCustom != null) { | ||
if (fromCustom < 0) { | ||
cir.setReturnValue(null); | ||
} else { | ||
cir.setReturnValue((A)new Compostable(fromCustom)); | ||
} | ||
} | ||
}); | ||
} else if (type == NeoForgeDataMaps.RAID_HERO_GIFTS) { | ||
registry.getHolder(key).ifPresent(holder -> { | ||
var fromCustom = VillagerInteractionRegistries.MODIFIED_GIFTS.get(holder.value()); | ||
if (fromCustom != null) { | ||
cir.setReturnValue((A) new RaidHeroGift(fromCustom)); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
...main/java/net/fabricmc/fabric/mixin/content/registry/AbstractFurnaceBlockEntityMixin.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...stries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/BaseRegistryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.fabricmc.fabric.mixin.content.registry; | ||
|
||
import net.fabricmc.fabric.impl.content.registry.DataMapModifications; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.neoforged.neoforge.registries.BaseMappedRegistry; | ||
import net.neoforged.neoforge.registries.datamaps.DataMapType; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(BaseMappedRegistry.class) | ||
public abstract class BaseRegistryMixin<T> { | ||
@Inject(at = @At("HEAD"), method = "getData", cancellable = true) | ||
private <A> void getDataMapConsideringFAPI(DataMapType<T, A> type, ResourceKey<T> key, CallbackInfoReturnable<A> cir) { | ||
DataMapModifications.modify((Registry<T>) this, type, key, cir); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters