pala M-hunter-5: capture sword/stone (14 types, CUSTOM_DATA)

This commit is contained in:
Anaïs Saraiva
2026-10-19 08:26:38 +02:00
parent 4da821104d
commit dcbf327a57
17 changed files with 162 additions and 0 deletions
@@ -145,6 +145,13 @@ public final class PalaItems {
// gameplay), sans bonus invente ; gate craft chasseur 4 non applicable (pas de
// gates craft). Textures legacy cast/uncast.
public static final Item PALADIUM_FISHING_ROD = register("paladium_fishing_rod", id -> new net.minecraft.world.item.FishingRodItem(new Item.Properties().setId(id).stacksTo(1).durability(384)));
// M-hunter-5 (wiki niv.13/14 VERIFIE : epee 32 utilisations, 1 pierre = 1 ame,
// 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).
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)));
public static final Item INFERNAL_KNOCKER = register("infernal_knocker", id -> new Item(new Item.Properties().setId(id).stacksTo(1).component(DataComponents.ATTRIBUTE_MODIFIERS,
net.minecraft.world.item.component.ItemAttributeModifiers.builder().add(
net.minecraft.world.entity.ai.attributes.Attributes.ATTACK_DAMAGE,
@@ -84,6 +84,9 @@ public final class PalaTabs {
output.accept(PalaItems.CAVE_HAMMER);
output.accept(PalaItems.INFERNAL_KNOCKER);
output.accept(PalaItems.PALADIUM_FISHING_ROD);
output.accept(PalaItems.CAPTURE_SWORD);
output.accept(PalaItems.CAPTURE_STONE_EMPTY);
output.accept(PalaItems.CAPTURE_STONE_FULL);
output.accept(PalaItems.SPAWNER_FINDER);
output.accept(PalaItems.DYNAMITE);
output.accept(PalaItems.NINJA_DYNAMITE);
@@ -173,6 +173,43 @@ public final class PalaItemUseEvents {
stack.hurtAndBreak(1, sp, hand);
return InteractionResult.SUCCESS;
}
// M-hunter-5 : pierre pleine — clic droit air, relache la creature visee
// (raycast 32, ECART : rend une pierre vide, spawn TRIGGERED).
if (item == PalaItems.CAPTURE_STONE_FULL) {
String typeId = stack.getOrDefault(
net.minecraft.core.component.DataComponents.CUSTOM_DATA,
net.minecraft.world.item.component.CustomData.EMPTY).copyTag()
.getString("pala:capture").orElse("");
if (typeId.isEmpty()) {
sp.sendSystemMessage(net.minecraft.network.chat.Component.literal(
"§cPierre vide (aucune ame)."));
return InteractionResult.PASS;
}
net.minecraft.world.phys.Vec3 start = sp.getEyePosition();
net.minecraft.world.phys.Vec3 look = sp.getLookAngle();
net.minecraft.world.phys.Vec3 end = start.add(look.x * 32.0, look.y * 32.0, look.z * 32.0);
net.minecraft.world.phys.BlockHitResult hit = sl.clip(
new net.minecraft.world.level.ClipContext(start, end,
net.minecraft.world.level.ClipContext.Block.OUTLINE,
net.minecraft.world.level.ClipContext.Fluid.NONE, sp));
if (hit.getType() != net.minecraft.world.phys.HitResult.Type.BLOCK) {
return InteractionResult.PASS;
}
net.minecraft.world.entity.EntityType<?> type = net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE
.getValue(net.minecraft.resources.Identifier.parse(typeId));
if (type == null) {
return InteractionResult.PASS;
}
net.minecraft.core.BlockPos target = hit.getBlockPos().above();
net.minecraft.world.entity.Entity spawned = type.spawn(sl, target,
net.minecraft.world.entity.EntitySpawnReason.TRIGGERED);
if (spawned == null) {
return InteractionResult.PASS;
}
stack.shrink(1);
sp.addItem(new net.minecraft.world.item.ItemStack(PalaItems.CAPTURE_STONE_EMPTY, 1));
return InteractionResult.SUCCESS;
}
// M-pillage-1 (wiki ID 4640/4641/4642) : dynamites — clic droit air, explosion
// au point vise (raycast 32). Ninja = sans son.
if (item == PalaItems.DYNAMITE || item == PalaItems.NINJA_DYNAMITE
@@ -94,6 +94,38 @@ public final class PalaJobEvents {
}
// M-hunter-2/4 (wiki niv.9) : infernal knocker — knockback amplifie sur wither
// quand tenu en main (x3 direction du coup ; 4 degats via attribut M-hunter-4).
// M-hunter-5 (wiki niv.13/14) : epee de capture — coup sur creature capturable
// + pierre vide en inventaire -> capture (type en CUSTOM_DATA), 1 utilisation.
if (killer instanceof ServerPlayer catcher
&& catcher.getMainHandItem().is(fr.surviepote.pala.PalaItems.CAPTURE_SWORD)) {
String captured = capturableId(entity, catcher.level());
if (captured != null) {
net.minecraft.world.entity.player.Inventory inv = catcher.getInventory();
for (int i = 0; i < inv.getContainerSize(); i++) {
net.minecraft.world.item.ItemStack slot = inv.getItem(i);
if (slot.is(fr.surviepote.pala.PalaItems.CAPTURE_STONE_EMPTY)) {
final String typeId = captured;
slot.shrink(1);
net.minecraft.world.item.ItemStack full = new net.minecraft.world.item.ItemStack(
fr.surviepote.pala.PalaItems.CAPTURE_STONE_FULL, 1);
net.minecraft.world.item.component.CustomData.update(
net.minecraft.core.component.DataComponents.CUSTOM_DATA,
full, tag -> tag.putString("pala:capture", typeId));
if (!inv.add(full)) {
net.minecraft.world.entity.item.ItemEntity drop = new net.minecraft.world.entity.item.ItemEntity(
catcher.level(), catcher.getX(), catcher.getY(), catcher.getZ(), full);
catcher.level().addFreshEntity(drop);
}
entity.discard();
catcher.getMainHandItem().hurtAndBreak(1, catcher,
net.minecraft.world.entity.EquipmentSlot.MAINHAND);
catcher.sendSystemMessage(net.minecraft.network.chat.Component.literal(
"§aCreature capturee : " + typeId));
break;
}
}
}
}
if (killer instanceof ServerPlayer knocker
&& knocker.getMainHandItem().is(fr.surviepote.pala.PalaItems.INFERNAL_KNOCKER)
&& entity.getType() == net.minecraft.world.entity.EntityTypes.WITHER) {
@@ -147,6 +179,25 @@ public final class PalaJobEvents {
}
}
// M-hunter-5 : creatures capturables (wiki VERIFIE, vanilla uniquement ; moddees
// SKIP M8). Wither : uniquement "dans les minages" -> ECART : hors overworld.
private static final java.util.Set<String> CAPTURABLES = java.util.Set.of(
"minecraft:pig", "minecraft:cow", "minecraft:sheep", "minecraft:slime",
"minecraft:zombie", "minecraft:creeper", "minecraft:rabbit", "minecraft:horse",
"minecraft:chicken", "minecraft:turtle", "minecraft:panda", "minecraft:dolphin",
"minecraft:parrot", "minecraft:goat");
private static String capturableId(LivingEntity entity, net.minecraft.world.level.Level level) {
String id = BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString();
if (CAPTURABLES.contains(id)) {
return id;
}
if (id.equals("minecraft:wither") && !level.dimension().equals(net.minecraft.world.level.Level.OVERWORLD)) {
return id;
}
return null;
}
/** Recolte vanilla : appele depuis PalaToolEvents.afterBreak (etat AVANT casse). */
public static void onHarvest(ServerPlayer player, BlockState state) {
Block block = state.getBlock();
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "pala:item/capture_stone_empty"
}
}
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "pala:item/capture_stone_full"
}
}
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "pala:item/capture_sword"
}
}
@@ -10,6 +10,9 @@
"item.pala.spawner_finder": "Chercheur de spawners",
"item.pala.infernal_knocker": "Infernal Knocker",
"item.pala.paladium_fishing_rod": "Paladium Fishing Rod",
"item.pala.capture_sword": "Capture Sword",
"item.pala.capture_stone_empty": "Capture Stone",
"item.pala.capture_stone_full": "Full Capture Stone",
"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/capture_stone_empty"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "pala:item/capture_stone_full"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "pala:item/capture_sword"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
"pala:compressed_amethyst",
"pala:compressed_titane",
"pala:titane_ore_block",
"minecraft:amethyst_block",
"minecraft:obsidian",
"minecraft:blaze_powder",
"minecraft:blaze_powder",
"minecraft:blaze_powder",
"minecraft:blaze_powder"
],
"result": {
"id": "pala:capture_stone_empty",
"count": 1
}
}