pala M-mixin: pipeline mixin + XP craft (pain/tarte) et cuisson (viandes)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package fr.surviepote.pala.mixin;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.ResultSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.CallbackInfo;
|
||||
|
||||
import fr.surviepote.pala.core.PalaJobs;
|
||||
|
||||
// M-mixin (wiki metiers, VERIFIE) : XP au craft, sans event fabric existant.
|
||||
// Fermier : pain = 1 XP (niveau 1+), tarte citrouille = 4 XP (niveau 11+), par item pris.
|
||||
// Injection en TAIL de checkTakeAchievements (appele a chaque prise du resultat).
|
||||
@Mixin(ResultSlot.class)
|
||||
public class PalaCraftXpMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Player player;
|
||||
|
||||
@Inject(method = "checkTakeAchievements", at = @At("TAIL"))
|
||||
private void pala$craftXp(ItemStack stack, CallbackInfo ci) {
|
||||
if (!(player instanceof ServerPlayer sp) || stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String id = net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(stack.getItem())
|
||||
.toString();
|
||||
if (id.equals("minecraft:bread")) {
|
||||
if (PalaJobs.levelOf(sp, "fermier") >= 1) {
|
||||
PalaJobs.addXp(sp, "fermier", 1.0 * stack.getCount());
|
||||
}
|
||||
} else if (id.equals("minecraft:pumpkin_pie")) {
|
||||
if (PalaJobs.levelOf(sp, "fermier") >= 11) {
|
||||
PalaJobs.addXp(sp, "fermier", 4.0 * stack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package fr.surviepote.pala.mixin;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.FurnaceResultSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.CallbackInfo;
|
||||
|
||||
import fr.surviepote.pala.core.PalaJobs;
|
||||
|
||||
// M-mixin (wiki chasseur, VERIFIE) : cuisson des viandes = 10 XP chasseur (niveau 1+),
|
||||
// par item pris. Lapin exclu (wiki : "sauf pour le lapin").
|
||||
// Injection en TAIL de onTake (signature vanilla verifiee au javap).
|
||||
@Mixin(FurnaceResultSlot.class)
|
||||
public class PalaSmeltXpMixin {
|
||||
|
||||
@Inject(method = "onTake", at = @At("TAIL"))
|
||||
private void pala$smeltXp(Player player, ItemStack stack, CallbackInfo ci) {
|
||||
if (!(player instanceof ServerPlayer sp) || stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String id = net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(stack.getItem())
|
||||
.toString();
|
||||
boolean viande = id.equals("minecraft:cooked_beef") || id.equals("minecraft:cooked_mutton")
|
||||
|| id.equals("minecraft:cooked_porkchop") || id.equals("minecraft:cooked_chicken");
|
||||
if (viande && PalaJobs.levelOf(sp, "chasseur") >= 1) {
|
||||
PalaJobs.addXp(sp, "chasseur", 10.0 * stack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
"main": ["fr.surviepote.pala.Pala"],
|
||||
"client": ["fr.surviepote.pala.PalaClient"]
|
||||
},
|
||||
"mixins": ["pala.mixins.json"],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.0",
|
||||
"fabric-api": "*",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "fr.surviepote.pala.mixin",
|
||||
"mixins": [
|
||||
"PalaCraftXpMixin",
|
||||
"PalaSmeltXpMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user