pala M-mineur-xp: gates niveaux, XP cuisson, XP hammer, bonbon jaune

This commit is contained in:
Anaïs Saraiva
2026-10-19 03:56:22 +02:00
parent 588e516dbe
commit 8c4a6748ef
8 changed files with 88 additions and 22 deletions
@@ -59,9 +59,9 @@ public final class PalaItems {
public static final Item TITANE_STICK = register("titane_stick", id -> new Item(new Item.Properties().setId(id)));
public static final Item TRIXIUM_GEM = register("trixium_gem", id -> new Item(new Item.Properties().setId(id)));
public static final Item XP_BERRIES = register("xp_berries", id -> new Item(new Item.Properties().setId(id)));
// M-candy (wiki metiers, VERIFIE partiel) : bonbons 50 000 XP. Vert = fermier et
// rainbow = tous (pages Evolution) ; autres couleurs = mapping non publie (items seuls,
// TODO:mapping-bonbons) ; candy/job_candy = nature inconnue (items seuls).
// M-candy (wiki metiers, VERIFIE partiel) : bonbons 50 000 XP. Vert = fermier,
// jaune = mineur, rainbow = tous (pages Evolution) ; bleu/rose = mapping non publie
// (items seuls, TODO:mapping-bonbons) ; candy/job_candy = nature inconnue (items seuls).
public static final Item CANDY = register("candy", id -> new Item(new Item.Properties().setId(id)));
public static final Item CANDY_BLUE = register("candy_blue", id -> new Item(new Item.Properties().setId(id)));
public static final Item CANDY_GREEN = register("candy_green", id -> new Item(new Item.Properties().setId(id)));
@@ -43,9 +43,24 @@ public final class PalaConfig {
Map.entry("pala:paladium_green_ore", 20.0), Map.entry("pala:trixium_ore", 10.0),
Map.entry("pala:findium_ore", 10.0)));
// Courbe XP : seuils wiki VERIFIES (page Evolution mineur, "XP necessaire" : les points
// sont des separateurs de milliers : 22.123 = 22 123). Niveaux 2-20 en table exacte ;
// au-dela : formule de prolongation (xpBase * n^xpExponent, UNVERIFIED). La table mineur
// M-mineur-xp (wiki Evolution mineur, VERIFIE) : niveaux requis par bloc.
// Niv.1 : roche/diorite/charbon/quartz/obsidienne/lapis/redstone/emeraude ;
// niv.5 : fer/or/diamant/amethyste/titane (+ minerais pala par interpretation
// "Particules paladium 20@5", ECART documente).
public Map<String, Integer> minerLevels = new HashMap<>(Map.ofEntries(
Map.entry("minecraft:stone", 1),
Map.entry("minecraft:diorite", 1), Map.entry("minecraft:andesite", 1),
Map.entry("minecraft:coal_ore", 1), Map.entry("minecraft:deepslate_coal_ore", 1),
Map.entry("minecraft:quartz_ore", 1), Map.entry("minecraft:obsidian", 1),
Map.entry("minecraft:lapis_ore", 1), Map.entry("minecraft:redstone_ore", 1),
Map.entry("minecraft:emerald_ore", 1), Map.entry("minecraft:deepslate_emerald_ore", 1),
Map.entry("minecraft:iron_ore", 5), Map.entry("minecraft:deepslate_iron_ore", 5),
Map.entry("minecraft:gold_ore", 5), Map.entry("minecraft:deepslate_gold_ore", 5),
Map.entry("minecraft:diamond_ore", 5), Map.entry("minecraft:deepslate_diamond_ore", 5),
Map.entry("pala:amethyst_ore", 5), Map.entry("pala:titane_ore", 5),
Map.entry("pala:paladium_ore", 5), Map.entry("pala:paladium_green_ore", 5),
Map.entry("pala:trixium_ore", 5), Map.entry("pala:findium_ore", 5)));
// Courbe XP (M-xpcurve) : seuils wiki VERIFIES 2-20, formule au-dela. La table mineur
// s'applique aux 4 metiers (seule table publiee ; ECART documente).
public double xpBase = 100.0;
public double xpExponent = 1.5;
@@ -164,6 +179,9 @@ public final class PalaConfig {
if (loaded.minerXp != null && !loaded.minerXp.isEmpty()) {
instance.minerXp = loaded.minerXp;
}
if (loaded.minerLevels != null && !loaded.minerLevels.isEmpty()) {
instance.minerLevels = loaded.minerLevels;
}
if (loaded.xpBase > 0) {
instance.xpBase = loaded.xpBase;
}
@@ -205,8 +223,8 @@ public final class PalaConfig {
// absents gardent leurs valeurs par defaut, jamais null), on re-sauvegarde
// pour les materialiser si une cle attendue manque. Une table explicitement
// videe (cle presente, tableau vide) est respectee telle quelle.
java.util.Set<String> expected = java.util.Set.of("minerXp", "xpBase",
"xpExponent", "levelThresholds", "netherMinerLevel", "stickCooldowns",
java.util.Set<String> expected = java.util.Set.of("minerXp", "minerLevels",
"xpBase", "xpExponent", "levelThresholds", "netherMinerLevel", "stickCooldowns",
"rankNodes", "hunterKills", "farmerHarvest", "crusherXp",
"crusherResults", "crusherFuels", "crusherInfiniteFuels",
"furnaceSmelts", "furnaceFuels",
@@ -49,7 +49,7 @@ public final class PalaJobs {
return data.level;
}
/** Hook casse-bloc : XP mineur selon la table config. Appele depuis PalaToolEvents. */
/** Hook casse-bloc : XP mineur selon la table config + niveau requis (wiki). */
public static void onBlockBreak(ServerPlayer player, ServerLevel level, BlockPos pos, BlockState state) {
Identifier id = level.registryAccess()
.lookupOrThrow(net.minecraft.core.registries.Registries.BLOCK)
@@ -58,8 +58,42 @@ public final class PalaJobs {
return;
}
Double xp = PalaConfig.get().minerXp.get(id.toString());
if (xp != null) {
if (xp != null && levelOf(player, "mineur") >= PalaConfig.get().minerLevels
.getOrDefault(id.toString(), 0)) {
addXp(player, "mineur", xp);
}
}
/** Hook prise fourneau : cuisson mineur (table wiki "Cuire") + viandes chasseur. */
public static void onSmeltTake(ServerPlayer player, net.minecraft.world.item.ItemStack stack) {
if (stack.isEmpty()) {
return;
}
String id = net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(stack.getItem())
.toString();
// Viandes chasseur (wiki : 10 XP, sauf lapin).
boolean viande = id.equals("minecraft:cooked_beef") || id.equals("minecraft:cooked_mutton")
|| id.equals("minecraft:cooked_porkchop") || id.equals("minecraft:cooked_chicken");
if (viande) {
if (levelOf(player, "chasseur") >= 1) {
addXp(player, "chasseur", 10.0 * stack.getCount());
}
return;
}
// Cuisson mineur : [xp, niveau] (wiki "Cuire les objets").
double[] table = SMELT_MINER.get(id);
if (table != null && levelOf(player, "mineur") >= (int) table[1]) {
addXp(player, "mineur", table[0] * stack.getCount());
}
}
private static final java.util.Map<String, double[]> SMELT_MINER = java.util.Map.of(
"minecraft:nether_brick", new double[]{0.1, 1},
"minecraft:charcoal", new double[]{6, 1},
"minecraft:iron_ingot", new double[]{8, 2},
"minecraft:gold_ingot", new double[]{30, 4},
"pala:amethyst_ingot", new double[]{35, 5},
"pala:titane_ingot", new double[]{50, 7},
"pala:paladium_ingot", new double[]{150, 10},
"pala:paladium_green_ingot", new double[]{200, 12});
}
@@ -118,13 +118,18 @@ public final class PalaItemUseEvents {
stack.shrink(1);
return InteractionResult.PASS;
}
// M-candy (wiki metiers) : bonbon vert = +50 000 XP fermier, rainbow = +50 000 aux
// 4 metiers. Autres couleurs : mapping non publie (TODO:mapping-bonbons, sans effet).
// M-candy (wiki metiers) : bonbon vert = +50 000 XP fermier, jaune = mineur,
// rainbow = +50 000 aux 4 metiers. Bleu/rose : mapping non publie (sans effet).
if (item == PalaItems.CANDY_GREEN) {
fr.surviepote.pala.core.PalaJobs.addXp(sp, "fermier", 50000.0);
stack.shrink(1);
return InteractionResult.PASS;
}
if (item == PalaItems.CANDY_YELLOW) {
fr.surviepote.pala.core.PalaJobs.addXp(sp, "mineur", 50000.0);
stack.shrink(1);
return InteractionResult.PASS;
}
if (item == PalaItems.CANDY_RAINBOW) {
for (String job : fr.surviepote.pala.core.PalaJobs.JOBS) {
fr.surviepote.pala.core.PalaJobs.addXp(sp, job, 50000.0);
@@ -359,7 +359,16 @@ public final class PalaToolEvents {
if (state.getDestroySpeed(level, target) < 0.0F) {
continue;
}
level.destroyBlock(target, true, player, 512);
// M-mineur-xp (wiki : "avec un hammer vous gagnez 4,5 par coup" = 9 x 0,5) :
// chaque bloc casse donne son XP mineur (gate niveau + pas de silk-touch).
// ECART : contredit "miner avec un hammer ne rapporte pas d'XP" (meme page) ;
// choix du chiffre (4,5 = 9 blocs), documente.
if (level.destroyBlock(target, true, player, 512)) {
ItemStack hand = player.getMainHandItem();
if (!hasSilkTouch(level, hand)) {
fr.surviepote.pala.core.PalaJobs.onBlockBreak(player, level, target, state);
}
}
}
}
@@ -19,15 +19,8 @@ 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());
if (player instanceof ServerPlayer sp) {
PalaJobs.onSmeltTake(sp, stack);
}
}
}