Bonjour,
J'ai avec un ami une aventure avec un modpack en 1.20.1 avec forge 47.3.0 qui contient le mod samurai dynasty. Dans ce mod se trouve un item que je charche a modifier (une arme) elle applique des effets en tapant et en donne au joueur avec le clique droit. J'ai bien réussi a décompresser le .jar, accéder au fichier .class et a le décompiler pour accéder au Java (que j'ai modifier) mais quand je tente de recompiler le .java en .class avec javac il me lance une volée d'erreurs que je n'explique pas (voici ma console):
Pourtant, le code java qui suit n'as été modifier que sur l'intérieur des fonctions et l'ajout d'effet:
est ce que vous pourriez m'aider afin que je puisse modifier cela (soit en m'aidant sur la compilation soit en me donnant une autre maniere de faire)
J'ai avec un ami une aventure avec un modpack en 1.20.1 avec forge 47.3.0 qui contient le mod samurai dynasty. Dans ce mod se trouve un item que je charche a modifier (une arme) elle applique des effets en tapant et en donne au joueur avec le clique droit. J'ai bien réussi a décompresser le .jar, accéder au fichier .class et a le décompiler pour accéder au Java (que j'ai modifier) mais quand je tente de recompiler le .java en .class avec javac il me lance une volée d'erreurs que je n'explique pas (voici ma console):
Code:
C:\Minecraft\mods\sumurai_dynasty>javac net/veroxuniverse/samurai_dynasty/item/AkanameKatanaItem.java
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:9: error: package net.minecraft does not exist
import net.minecraft.ChatFormatting;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:10: error: package net.minecraft.client.gui.screens does not exist
import net.minecraft.client.gui.screens.Screen;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:11: error: package net.minecraft.network.chat does not exist
import net.minecraft.network.chat.Component;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:12: error: package net.minecraft.network.chat does not exist
import net.minecraft.network.chat.MutableComponent;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:13: error: package net.minecraft.sounds does not exist
import net.minecraft.sounds.SoundEvents;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:14: error: package net.minecraft.sounds does not exist
import net.minecraft.sounds.SoundSource;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:15: error: package net.minecraft.util does not exist
import net.minecraft.util.RandomSource;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:16: error: package net.minecraft.world does not exist
import net.minecraft.world.InteractionHand;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:17: error: package net.minecraft.world does not exist
import net.minecraft.world.InteractionResultHolder;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:18: error: package net.minecraft.world.effect does not exist
import net.minecraft.world.effect.MobEffectInstance;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:19: error: package net.minecraft.world.effect does not exist
import net.minecraft.world.effect.MobEffects;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:20: error: package net.minecraft.world.entity does not exist
import net.minecraft.world.entity.Entity;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:21: error: package net.minecraft.world.entity does not exist
import net.minecraft.world.entity.LivingEntity;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:22: error: package net.minecraft.world.entity.player does not exist
import net.minecraft.world.entity.player.Player;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:24: error: package net.minecraft.world.level does not exist
import net.minecraft.world.level.Level;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:25: error: package net.minecraftforge.registries does not exist
import net.minecraftforge.registries.RegistryObject;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:28: error: cannot find symbol
public class AkanameKatanaItem extends SwordItem
^
symbol: class SwordItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:31: error: cannot find symbol
public AkanameKatanaItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, net.minecraft.world.item.Item.Properties pProperties)
^
symbol: class Tier
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:31: error: cannot access Properties
public AkanameKatanaItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, net.minecraft.world.item.Item.Properties pProperties)
^
class file for net.minecraft.world.item.Item$Properties not found
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:36: error: cannot find symbol
public void m_7373_(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag)
^
symbol: class ItemStack
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:36: error: cannot find symbol
public void m_7373_(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag)
^
symbol: class Level
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:36: error: cannot find symbol
public void m_7373_(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag)
^
symbol: class TooltipFlag
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:53: error: cannot find symbol
public InteractionResultHolder m_7203_(Level pLevel, Player pPlayer, InteractionHand pHand)
^
symbol: class Level
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:53: error: cannot find symbol
public InteractionResultHolder m_7203_(Level pLevel, Player pPlayer, InteractionHand pHand)
^
symbol: class Player
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:53: error: cannot find symbol
public InteractionResultHolder m_7203_(Level pLevel, Player pPlayer, InteractionHand pHand)
^
symbol: class InteractionHand
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:53: error: cannot find symbol
public InteractionResultHolder m_7203_(Level pLevel, Player pPlayer, InteractionHand pHand)
^
symbol: class InteractionResultHolder
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:67: error: cannot find symbol
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity)
^
symbol: class ItemStack
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:67: error: cannot find symbol
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity)
^
symbol: class Player
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:67: error: cannot find symbol
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity)
^
symbol: class Entity
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:23: error: package net.minecraft.world.item does not exist
import net.minecraft.world.item.*;
^
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:36: error: cannot find symbol
public void m_7373_(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag)
^
symbol: class Nullable
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:52: error: cannot find symbol
@NotNull
^
symbol: class NotNull
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:38: error: cannot find symbol
if(Screen.m_96638_() && stack.m_41720_() == ItemsRegistry.KATANA_AKANAME.get())
^
symbol: variable Screen
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:38: error: cannot access RegistryObject
if(Screen.m_96638_() && stack.m_41720_() == ItemsRegistry.KATANA_AKANAME.get())
^
class file for net.minecraftforge.registries.RegistryObject not found
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:40: error: cannot find symbol
components.add(Component.m_237113_("\2478Hold [\2477Shift\2478] for Summary"));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:41: error: cannot find symbol
components.add(Component.m_237113_(""));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:42: error: cannot find symbol
components.add(Component.m_237113_("\2477Applies \247bSlowness\2477 on hit.").m_130940_(ChatFormatting.GRAY));
^
symbol: variable ChatFormatting
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:42: error: cannot find symbol
components.add(Component.m_237113_("\2477Applies \247bSlowness\2477 on hit.").m_130940_(ChatFormatting.GRAY));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:43: error: cannot find symbol
components.add(Component.m_237113_(""));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:44: error: cannot find symbol
components.add(Component.m_237113_("\2477Ability [\247eRight-Click\2477]"));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:45: error: cannot find symbol
components.add(Component.m_237113_("\2477Applies \247bStrength\2477.").m_130940_(ChatFormatting.GRAY));
^
symbol: variable ChatFormatting
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:45: error: cannot find symbol
components.add(Component.m_237113_("\2477Applies \247bStrength\2477.").m_130940_(ChatFormatting.GRAY));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:48: error: cannot find symbol
components.add(Component.m_237113_("\2478Hold [\2477Shift\2478] for Summary"));
^
symbol: variable Component
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:49: error: cannot find symbol
super.m_7373_(stack, level, components, flag);
^
symbol: variable super
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:55: error: cannot find symbol
ItemStack itemstack = pPlayer.m_21120_(pHand);
^
symbol: class ItemStack
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:56: error: cannot find symbol
if(pHand == InteractionHand.MAIN_HAND)
^
symbol: variable InteractionHand
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:59: error: cannot find symbol
pLevel.m_6263_((Player)null, pPlayer.m_20185_(), pPlayer.m_20186_(), pPlayer.m_20189_(), SoundEvents.f_11887_, SoundSource.NEUTRAL, 1.0F, 1.0F / (pLevel.m_213780_().m_188501_() * 0.4F + 0.8F));
^
symbol: class Player
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:59: error: cannot find symbol
pLevel.m_6263_((Player)null, pPlayer.m_20185_(), pPlayer.m_20186_(), pPlayer.m_20189_(), SoundEvents.f_11887_, SoundSource.NEUTRAL, 1.0F, 1.0F / (pLevel.m_213780_().m_188501_() * 0.4F + 0.8F));
^
symbol: variable SoundEvents
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:59: error: cannot find symbol
pLevel.m_6263_((Player)null, pPlayer.m_20185_(), pPlayer.m_20186_(), pPlayer.m_20189_(), SoundEvents.f_11887_, SoundSource.NEUTRAL, 1.0F, 1.0F / (pLevel.m_213780_().m_188501_() * 0.4F + 0.8F));
^
symbol: variable SoundSource
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:60: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19600_, 6000, 2, false, false, false), pPlayer);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:60: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19600_, 6000, 2, false, false, false), pPlayer);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:61: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19596_, 6000, 2, false, false, false), pPlayer);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:61: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19596_, 6000, 2, false, false, false), pPlayer);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:62: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19607_, 6000, 0, false, false, false), pPlayer);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:62: error: cannot find symbol
pPlayer.m_147207_(new MobEffectInstance(MobEffects.f_19607_, 6000, 0, false, false, false), pPlayer);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:64: error: cannot find symbol
return InteractionResultHolder.m_19092_(itemstack, pLevel.m_5776_());
^
symbol: variable InteractionResultHolder
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:69: error: cannot find symbol
if(entity instanceof LivingEntity)
^
symbol: class LivingEntity
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:71: error: cannot find symbol
LivingEntity livingEntity = (LivingEntity)entity;
^
symbol: class LivingEntity
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:71: error: cannot find symbol
LivingEntity livingEntity = (LivingEntity)entity;
^
symbol: class LivingEntity
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:72: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19597_, 60, 1), player);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:72: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19597_, 60, 1), player);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:73: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19615_, 200, 1), player);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:73: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19615_, 200, 1), player);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:74: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19597_, 200, 1), player);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:74: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19597_, 200, 1), player);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:75: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19610_, 200, 1), player);
^
symbol: class MobEffectInstance
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:75: error: cannot find symbol
livingEntity.m_147207_(new MobEffectInstance(MobEffects.f_19610_, 200, 1), player);
^
symbol: variable MobEffects
location: class AkanameKatanaItem
net\veroxuniverse\samurai_dynasty\item\AkanameKatanaItem.java:77: error: cannot find symbol
return super.onLeftClickEntity(stack, player, entity);
^
symbol: variable super
location: class AkanameKatanaItem
68 errors
Pourtant, le code java qui suit n'as été modifier que sur l'intérieur des fonctions et l'ajout d'effet:
Java:
package net.veroxuniverse.samurai_dynasty.item;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.veroxuniverse.samurai_dynasty.registry.ItemsRegistry;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Properties;
public class AkanameKatanaItem extends SwordItem {
public AkanameKatanaItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier,
Properties pProperties) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag flag) {
if (Screen.hasShiftDown() && stack.getItem() == ItemsRegistry.KATANA_AKANAME.get()) {
components.add(Component.literal("§8Hold [§7Shift§8] for Summary"));
components.add(Component.literal(""));
components.add(Component.literal("§7Applies §bSlowness§7 on hit.").withStyle(ChatFormatting.GRAY));
components.add(Component.literal(""));
components.add(Component.literal("§7Ability [§eRight-Click§7]"));
components.add(Component.literal("§7Applies §bStrength§7.").withStyle(ChatFormatting.GRAY));
} else if (stack.getItem() == ItemsRegistry.KATANA_AKANAME.get()) {
components.add(Component.literal("§8Hold [§7Shift§8] for Summary"));
}
super.appendHoverText(stack, level, components, flag);
}
public @NotNull InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pHand) {
ItemStack itemstack = pPlayer.getItemInHand(pHand);
if (pHand == InteractionHand.MAIN_HAND) {
pPlayer.getCooldowns().addCooldown(this, 6000);
pLevel.playSound((Player) null, pPlayer.getX(), pPlayer.getY(), pPlayer.getZ(),
SoundEvents.ENCHANTMENT_TABLE_USE, SoundSource.NEUTRAL, 1.0F,
1.0F / (pLevel.getRandom().nextFloat() * 0.4F + 0.8F));
pPlayer.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 6000, 2, false, false, false), pPlayer);
pPlayer.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 6000, 2, false, false, false), pPlayer);
pPlayer.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 1, false, false, false), pPlayer);
pPlayer.addEffect(new MobEffectInstance(MobEffects.RESISTANCE, 6000, 2, false, false, false), pPlayer);
pPlayer.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 6000, 1, false, false, false), pPlayer);
pPlayer.addEffect(new MobEffectInstance(MobEffects.HEALTH_BOOST, 6000, 1, false, false, false), pPlayer);
}
return InteractionResultHolder.sidedSuccess(itemstack, pLevel.isClientSide());
}
@Override
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) {
if (entity instanceof LivingEntity livingEntity) {
livingEntity.addEffect(new MobEffectInstance(MobEffects.WITHER, 200, 1), player);
livingEntity.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 200, 1), player);
livingEntity.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 200, 1), player);
livingEntity.addEffect(new MobEffectInstance(MobEffects.WEAKNESS, 200, 1), player);
livingEntity.addEffect(new MobEffectInstance(MobEffects.POISON, 200, 1), player);
}
return super.onLeftClickEntity(stack, player, entity);
}
}
est ce que vous pourriez m'aider afin que je puisse modifier cela (soit en m'aidant sur la compilation soit en me donnant une autre maniere de faire)
Dernière édition par un modérateur: