pala M-hunter-6: etiquette endium (rename, max 3)
This commit is contained in:
@@ -149,6 +149,9 @@ public final class PalaItems {
|
||||
// pleines non stackables, epee utilisable avant niv.13) : capture d'entites.
|
||||
// ECART : degats epee non publies (Item simple), crafts exacts (positions image
|
||||
// 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_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)));
|
||||
|
||||
@@ -87,6 +87,7 @@ public final class PalaTabs {
|
||||
output.accept(PalaItems.CAPTURE_SWORD);
|
||||
output.accept(PalaItems.CAPTURE_STONE_EMPTY);
|
||||
output.accept(PalaItems.CAPTURE_STONE_FULL);
|
||||
output.accept(PalaItems.ENDIUM_NAMETAG);
|
||||
output.accept(PalaItems.SPAWNER_FINDER);
|
||||
output.accept(PalaItems.DYNAMITE);
|
||||
output.accept(PalaItems.NINJA_DYNAMITE);
|
||||
|
||||
@@ -39,6 +39,9 @@ public final class PalaStorage {
|
||||
public double money = 0.0;
|
||||
// M-homes-1 : homes personnels (nom -> "dimension:x:y:z").
|
||||
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() {
|
||||
UseItemCallback.EVENT.register(PalaItemUseEvents::onUseItem);
|
||||
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) {
|
||||
|
||||
@@ -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_stone_empty": "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.magma_amulet": "Amulette de feu",
|
||||
"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 |
Reference in New Issue
Block a user