001package net.tnemc.item.component.helper;
002/*
003 * The New Item Library
004 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020
021import java.util.ArrayList;
022
023/**
024 * ItemDamage - Controls how much damage should be applied to the item from a given attack
025 * If not specified, a point of durability is removed for every point of damage dealt
026 * The final damage applied to the item is determined by: floor(base + factor * dealt_damage)
027 * The final value may be negative, causing the item to be repaired
028 * @author creatorfromhell
029 * @since 0.2.0.0
030 * @see net.tnemc.item.component.impl.BlocksAttacksComponent
031 */
032public class ItemDamage {
033
034  protected final float threshold;
035  protected final float base;
036  protected final float factor;
037
038  public ItemDamage(final float threshold, final float base, final float factor) {
039
040    this.threshold = threshold;
041    this.base = base;
042    this.factor = factor;
043  }
044
045  public float threshold() {
046
047    return threshold;
048  }
049
050  public float base() {
051
052    return base;
053  }
054
055  public float factor() {
056
057    return factor;
058  }
059
060  @Override
061  public ItemDamage clone() throws CloneNotSupportedException {
062    return new ItemDamage(this.threshold, this.base, this.factor);
063  }
064}