-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
将ItemModelShaperMixin放置在fabric端,对forge端另作修改
- Loading branch information
Showing
6 changed files
with
63 additions
and
4 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
2 changes: 1 addition & 1 deletion
2
...estivals/mixins/ItemModelShaperMixin.java → ...s/fabric/mixins/ItemModelShaperMixin.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
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
46 changes: 46 additions & 0 deletions
46
forge/src/main/java/dev/dubhe/chinesefestivals/forge/mixins/ForgeItemModelShaperMixin.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,46 @@ | ||
package dev.dubhe.chinesefestivals.forge.mixins; | ||
|
||
import dev.dubhe.chinesefestivals.ChineseFestivals; | ||
import dev.dubhe.chinesefestivals.festivals.Festivals; | ||
import dev.dubhe.chinesefestivals.festivals.IFestival; | ||
import net.minecraft.client.renderer.ItemModelShaper; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.client.resources.model.ModelManager; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraftforge.client.model.ForgeItemModelShaper; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
@Mixin(ForgeItemModelShaper.class) | ||
public abstract class ForgeItemModelShaperMixin extends ItemModelShaper { | ||
@Shadow(remap = false) | ||
@Final | ||
private Map<Holder.Reference<Item>, BakedModel> models; | ||
|
||
public ForgeItemModelShaperMixin(ModelManager arg) { | ||
super(arg); | ||
} | ||
|
||
@Inject(method = "getItemModel", remap = false, at = @At("HEAD"), cancellable = true) | ||
private void getItemModel(Item item, CallbackInfoReturnable<BakedModel> cir) { | ||
ChineseFestivals.LOGGER.info("test"); | ||
for (IFestival festival : Festivals.FESTIVALS) { | ||
if (festival.isNow()) { | ||
Supplier<Item> item1 = festival.getItemReplace().getOrDefault(item, null); | ||
if (item1 != null) { | ||
cir.setReturnValue(this.models.get(ForgeRegistries.ITEMS.getDelegateOrThrow(item1.get()))); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "dev.dubhe.chinesefestivals.forge.mixins", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [], | ||
"client": [ | ||
"ForgeItemModelShaperMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |