pala M-hunter-6: etiquette endium (rename, max 3)

This commit is contained in:
Anaïs Saraiva
2026-10-19 08:33:18 +02:00
parent dcbf327a57
commit b91cf69e6f
10 changed files with 72 additions and 0 deletions
+4
View File
@@ -763,6 +763,10 @@ avant M4 (TODO:crafts-machines).
ECART ingrédients, pierre craftee 9 shapeless). Lecon : ENTITY_TYPE.getValue ECART ingrédients, pierre craftee 9 shapeless). Lecon : ENTITY_TYPE.getValue
retourne direct (@Nullable, pas Optional) ; CompoundTag.getString = Optional. retourne direct (@Nullable, pas Optional) ; CompoundTag.getString = Optional.
VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu. VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
- M-hunter-6 LIVRE 2026-10-19 ~08:30 : etiquette endium (UseEntityCallback javap,
nom enclume, max 3 persistee, 4e retire surnom 1ere, sans craft ECART). Lecon :
sp.server prive -> sp.level().getServer(). VERIFIE : build SUCCESSFUL, boot
Done, 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
@@ -149,6 +149,9 @@ public final class PalaItems {
// pleines non stackables, epee utilisable avant niv.13) : capture d'entites. // pleines non stackables, epee utilisable avant niv.13) : capture d'entites.
// ECART : degats epee non publies (Item simple), crafts exacts (positions image // ECART : degats epee non publies (Item simple), crafts exacts (positions image
// non OCR + strength stick/tete epee sans ids -> pierre seule craftee, epee sans). // non OCR + strength stick/tete epee sans ids -> pierre seule craftee, epee sans).
// M-hunter-6 (wiki niv.18 VERIFIE : renomme 1 entite, max 3, la 4e fait perdre
// le surnom a la 1ere ; nom via rename enclume comme nametag vanilla, ECART).
public static final Item ENDIUM_NAMETAG = register("endium_nametag", id -> new Item(new Item.Properties().setId(id).stacksTo(16)));
public static final Item CAPTURE_SWORD = register("capture_sword", id -> new Item(new Item.Properties().setId(id).stacksTo(1).durability(32))); public static final Item CAPTURE_SWORD = register("capture_sword", id -> new Item(new Item.Properties().setId(id).stacksTo(1).durability(32)));
public static final Item CAPTURE_STONE_EMPTY = register("capture_stone_empty", id -> new Item(new Item.Properties().setId(id))); public static final Item CAPTURE_STONE_EMPTY = register("capture_stone_empty", id -> new Item(new Item.Properties().setId(id)));
public static final Item CAPTURE_STONE_FULL = register("capture_stone_full", id -> new Item(new Item.Properties().setId(id).stacksTo(1))); public static final Item CAPTURE_STONE_FULL = register("capture_stone_full", id -> new Item(new Item.Properties().setId(id).stacksTo(1)));
@@ -87,6 +87,7 @@ public final class PalaTabs {
output.accept(PalaItems.CAPTURE_SWORD); output.accept(PalaItems.CAPTURE_SWORD);
output.accept(PalaItems.CAPTURE_STONE_EMPTY); output.accept(PalaItems.CAPTURE_STONE_EMPTY);
output.accept(PalaItems.CAPTURE_STONE_FULL); output.accept(PalaItems.CAPTURE_STONE_FULL);
output.accept(PalaItems.ENDIUM_NAMETAG);
output.accept(PalaItems.SPAWNER_FINDER); output.accept(PalaItems.SPAWNER_FINDER);
output.accept(PalaItems.DYNAMITE); output.accept(PalaItems.DYNAMITE);
output.accept(PalaItems.NINJA_DYNAMITE); output.accept(PalaItems.NINJA_DYNAMITE);
@@ -39,6 +39,9 @@ public final class PalaStorage {
public double money = 0.0; public double money = 0.0;
// M-homes-1 : homes personnels (nom -> "dimension:x:y:z"). // M-homes-1 : homes personnels (nom -> "dimension:x:y:z").
public Map<String, String> homes = new HashMap<>(); public Map<String, String> homes = new HashMap<>();
// M-hunter-6 : entites renommees par etiquette endium (joueur UUID -> liste
// ordonnee d'entites UUID, max 3).
public Map<String, java.util.List<String>> endiumTags = new HashMap<>();
} }
@@ -48,6 +48,54 @@ public final class PalaItemUseEvents {
public static void register() { public static void register() {
UseItemCallback.EVENT.register(PalaItemUseEvents::onUseItem); UseItemCallback.EVENT.register(PalaItemUseEvents::onUseItem);
UseBlockCallback.EVENT.register(PalaItemUseEvents::onUseBlock); UseBlockCallback.EVENT.register(PalaItemUseEvents::onUseBlock);
net.fabricmc.fabric.api.event.player.UseEntityCallback.EVENT.register(PalaItemUseEvents::onUseEntity);
}
// M-hunter-6 (wiki niv.18) : etiquette endium — renomme 1 entite vivante
// (nom via enclume), max 3 par joueur, la 4e fait perdre le surnom a la 1ere.
private static net.minecraft.world.InteractionResult onUseEntity(
net.minecraft.world.entity.player.Player player,
net.minecraft.world.level.Level level,
net.minecraft.world.InteractionHand hand,
net.minecraft.world.entity.Entity entity,
net.minecraft.world.phys.EntityHitResult hit) {
if (level.isClientSide() || !(player instanceof ServerPlayer sp)
|| !(entity instanceof net.minecraft.world.entity.LivingEntity living)
|| entity instanceof ServerPlayer) {
return net.minecraft.world.InteractionResult.PASS;
}
net.minecraft.world.item.ItemStack stack = sp.getItemInHand(hand);
if (!stack.is(PalaItems.ENDIUM_NAMETAG)) {
return net.minecraft.world.InteractionResult.PASS;
}
net.minecraft.network.chat.Component name = stack.getCustomName();
if (name == null) {
sp.sendSystemMessage(net.minecraft.network.chat.Component.literal(
"§cRenommez l'etiquette en enclume d'abord."));
return net.minecraft.world.InteractionResult.PASS;
}
fr.surviepote.pala.core.PalaStorage store =
fr.surviepote.pala.core.PalaStorage.get();
java.util.List<String> tagged = store.data(sp.getUUID()).endiumTags
.computeIfAbsent(sp.getUUID().toString(), k -> new java.util.ArrayList<>());
String entityId = entity.getUUID().toString();
if (!tagged.contains(entityId)) {
while (tagged.size() >= 3) {
String oldest = tagged.remove(0);
for (net.minecraft.server.level.ServerLevel sl : sp.level().getServer().getAllLevels()) {
net.minecraft.world.entity.Entity old = sl.getEntity(java.util.UUID.fromString(oldest));
if (old instanceof net.minecraft.world.entity.LivingEntity oldLiving) {
oldLiving.setCustomName(null);
}
}
}
tagged.add(entityId);
store.markDirty();
}
living.setCustomName(name);
living.setCustomNameVisible(true);
stack.shrink(1);
return net.minecraft.world.InteractionResult.SUCCESS;
} }
private static void effect(Player player, Holder<MobEffect> effect, int duration, int amplifier) { private static void effect(Player player, Holder<MobEffect> effect, int duration, int amplifier) {
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "pala:item/endium_nametag"
}
}
@@ -13,6 +13,7 @@
"item.pala.capture_sword": "Capture Sword", "item.pala.capture_sword": "Capture Sword",
"item.pala.capture_stone_empty": "Capture Stone", "item.pala.capture_stone_empty": "Capture Stone",
"item.pala.capture_stone_full": "Full Capture Stone", "item.pala.capture_stone_full": "Full Capture Stone",
"item.pala.endium_nametag": "Endium Tag",
"item.pala.cave_hammer": "Marteau des cavernes", "item.pala.cave_hammer": "Marteau des cavernes",
"item.pala.magma_amulet": "Amulette de feu", "item.pala.magma_amulet": "Amulette de feu",
"enchantment.pala.experience_bottler": "Experience Bottler", "enchantment.pala.experience_bottler": "Experience Bottler",
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "pala:item/endium_nametag"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.