pala M-enchants-1: voleur dXP (datapack + hook vol)
This commit is contained in:
@@ -701,6 +701,11 @@ avant M4 (TODO:crafts-machines).
|
|||||||
- M-alchi-4 LIVRE 2026-10-19 ~06:45 : bibliotheque mystique (ID 2955, texture legacy,
|
- M-alchi-4 LIVRE 2026-10-19 ~06:45 : bibliotheque mystique (ID 2955, texture legacy,
|
||||||
loot self, decorative v1). ECART : nouveaux enchantements en TODO:M-enchants, sans
|
loot self, decorative v1). ECART : nouveaux enchantements en TODO:M-enchants, sans
|
||||||
craft. VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
|
craft. VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
|
||||||
|
- M-enchants-1 LIVRE 2026-10-19 ~06:50 : voleur d'XP (datapack 4 niveaux + hook
|
||||||
|
afterDamage : 2 %/40, 4 %/50, 7 %/70, 10 %/90 XP vanilla). ECART : table moddee
|
||||||
|
absente (table vanilla/enclume//enchant). TODO:M-enchants partiel (bottler,
|
||||||
|
overwhelmed, unclaim, anti-chute infaisable serveur, fake-water sans degats).
|
||||||
|
VERIFIE : build SUCCESSFUL, boot Done (datapack accepte), 0 erreur. UNVERIFIED en jeu.
|
||||||
- M-palaforge LIVRE 2026-10-19 ~03:55 : bloc + BE partagee (3e mode) + gate mineur 14 +
|
- M-palaforge LIVRE 2026-10-19 ~03:55 : bloc + BE partagee (3e mode) + gate mineur 14 +
|
||||||
table fonte wiki §3.2 (31 items, ratio floor usure) + fuels bois (+buche/planches/baton,
|
table fonte wiki §3.2 (31 items, ratio floor usure) + fuels bois (+buche/planches/baton,
|
||||||
lave exclue : seau non rendu) + craft (1 findium + 4 furnaces + 4 briques, positions
|
lave exclue : seau non rendu) + craft (1 findium + 4 furnaces + 4 briques, positions
|
||||||
|
|||||||
@@ -42,6 +42,39 @@ public final class PalaJobEvents {
|
|||||||
// M-alchi-2 (wiki objets alchimiste) : capture d'eclair — foudre sur joueur avec
|
// M-alchi-2 (wiki objets alchimiste) : capture d'eclair — foudre sur joueur avec
|
||||||
// casque fer/or + fiole vanilla en main = 1 fiole -> lightning potion + 30 XP@1.
|
// casque fer/or + fiole vanilla en main = 1 fiole -> lightning potion + 30 XP@1.
|
||||||
// Degats conserves (risque de mort fidele au wiki).
|
// Degats conserves (risque de mort fidele au wiki).
|
||||||
|
// M-enchants-1 (wiki enchants moddes, Hunter) : voleur d'XP — chance de voler
|
||||||
|
// l'XP vanilla de la victime (niv 1 : 2 %/40, niv 2 : 4 %/50, niv 3 : 7 %/70,
|
||||||
|
// niv 4 : 10 %/90). ECART : table moddee absente (table vanilla/enclume//enchant).
|
||||||
|
private static void xpStealer(ServerPlayer attacker, LivingEntity victim) {
|
||||||
|
net.minecraft.world.item.ItemStack weapon = attacker.getMainHandItem();
|
||||||
|
if (weapon.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> holder =
|
||||||
|
attacker.level().registryAccess()
|
||||||
|
.lookupOrThrow(net.minecraft.core.registries.Registries.ENCHANTMENT)
|
||||||
|
.getOrThrow(net.minecraft.resources.ResourceKey.create(
|
||||||
|
net.minecraft.core.registries.Registries.ENCHANTMENT,
|
||||||
|
net.minecraft.resources.Identifier.fromNamespaceAndPath(
|
||||||
|
"pala", "xp_stealer")));
|
||||||
|
int level = net.minecraft.world.item.enchantment.EnchantmentHelper
|
||||||
|
.getItemEnchantmentLevel(holder, weapon);
|
||||||
|
if (level < 1 || level > 4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int[] chances = {0, 2, 4, 7, 10};
|
||||||
|
int[] amounts = {0, 40, 50, 70, 90};
|
||||||
|
if (Math.random() * 100.0 >= chances[level]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int take = amounts[level];
|
||||||
|
if (victim instanceof ServerPlayer target) {
|
||||||
|
take = Math.min(take, target.totalExperience);
|
||||||
|
target.giveExperiencePoints(-take);
|
||||||
|
}
|
||||||
|
attacker.giveExperiencePoints(take);
|
||||||
|
}
|
||||||
|
|
||||||
private static void afterDamage(LivingEntity entity, DamageSource source, float dealt,
|
private static void afterDamage(LivingEntity entity, DamageSource source, float dealt,
|
||||||
float taken, boolean blocked) {
|
float taken, boolean blocked) {
|
||||||
Entity killer = source.getEntity();
|
Entity killer = source.getEntity();
|
||||||
@@ -55,6 +88,10 @@ public final class PalaJobEvents {
|
|||||||
net.minecraft.sounds.SoundEvents.CHICKEN_EGG,
|
net.minecraft.sounds.SoundEvents.CHICKEN_EGG,
|
||||||
net.minecraft.sounds.SoundSource.PLAYERS, 1.0F, 1.0F);
|
net.minecraft.sounds.SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
// M-enchants-1 : vol d'XP a chaque coup porte par un joueur.
|
||||||
|
if (killer instanceof ServerPlayer attacker) {
|
||||||
|
xpStealer(attacker, entity);
|
||||||
|
}
|
||||||
if (entity instanceof ServerPlayer victim
|
if (entity instanceof ServerPlayer victim
|
||||||
&& source.is(net.minecraft.world.damagesource.DamageTypes.LIGHTNING_BOLT)) {
|
&& source.is(net.minecraft.world.damagesource.DamageTypes.LIGHTNING_BOLT)) {
|
||||||
net.minecraft.world.item.ItemStack head =
|
net.minecraft.world.item.ItemStack head =
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"item.pala.amethyst_mixed_coal": "Amethyst Mixed Coal",
|
"item.pala.amethyst_mixed_coal": "Amethyst Mixed Coal",
|
||||||
"item.pala.amethyst_stick": "Amethyst Stick",
|
"item.pala.amethyst_stick": "Amethyst Stick",
|
||||||
"item.pala.compressed_amethyst": "Compressed Amethyst",
|
"item.pala.compressed_amethyst": "Compressed Amethyst",
|
||||||
|
"enchantment.pala.xp_stealer": "Voleur d'XP",
|
||||||
"block.pala.mystical_bookshelf": "Bibliotheque mystique",
|
"block.pala.mystical_bookshelf": "Bibliotheque mystique",
|
||||||
"block.pala.cauldron_block": "Bloc du chaudron",
|
"block.pala.cauldron_block": "Bloc du chaudron",
|
||||||
"block.pala.cauldron_core": "Coeur du chaudron",
|
"block.pala.cauldron_core": "Coeur du chaudron",
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"anvil_cost": 4,
|
||||||
|
"description": {
|
||||||
|
"translate": "enchantment.pala.xp_stealer"
|
||||||
|
},
|
||||||
|
"effects": {
|
||||||
|
},
|
||||||
|
"max_cost": {
|
||||||
|
"base": 40,
|
||||||
|
"per_level_above_first": 10
|
||||||
|
},
|
||||||
|
"max_level": 4,
|
||||||
|
"min_cost": {
|
||||||
|
"base": 20,
|
||||||
|
"per_level_above_first": 10
|
||||||
|
},
|
||||||
|
"primary_items": "#minecraft:enchantable/sharp_weapon",
|
||||||
|
"slots": [
|
||||||
|
"mainhand"
|
||||||
|
],
|
||||||
|
"supported_items": "#minecraft:enchantable/sharp_weapon",
|
||||||
|
"weight": 2
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user