MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"it will give the player 5 wood swords"
/* To give the player 5 wood swords in Minecraft Forge, you can create a custom item that, when right-clicked, adds 5 wood swords to the player's inventory. */ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.world.World; public class GiveWoodSwordsItem extends Item { public GiveWoodSwordsItem(Properties properties) { super(properties); } @Override public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { if (!world.isClientSide) { ItemStack woodSwordStack = new ItemStack(Items.WOODEN_SWORD, 5); player.addItem(woodSwordStack); } return ActionResult.success(player.getItemInHand(hand)); } }