2018-10-19 18:32:20 +02:00
|
|
|
package de.ellpeck.naturesaura.items.tools;
|
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
import de.ellpeck.naturesaura.Helper;
|
2019-11-04 19:08:49 +01:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2020-01-29 00:40:28 +01:00
|
|
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
2018-10-20 21:19:08 +02:00
|
|
|
import de.ellpeck.naturesaura.items.ModItems;
|
2020-01-29 00:40:28 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
2018-10-19 18:32:20 +02:00
|
|
|
import de.ellpeck.naturesaura.reg.IModItem;
|
2020-01-22 01:32:26 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2019-11-04 19:08:49 +01:00
|
|
|
import net.minecraft.item.IItemTier;
|
2018-10-20 21:19:08 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.item.SwordItem;
|
|
|
|
import net.minecraft.nbt.CompoundNBT;
|
|
|
|
import net.minecraft.potion.EffectInstance;
|
2019-11-04 19:08:49 +01:00
|
|
|
import net.minecraft.potion.Effects;
|
2018-10-20 21:19:08 +02:00
|
|
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
2018-10-19 18:32:20 +02:00
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2020-01-29 00:40:28 +01:00
|
|
|
public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
2018-10-19 18:32:20 +02:00
|
|
|
private final String baseName;
|
|
|
|
|
2020-01-26 01:41:49 +01:00
|
|
|
public ItemSword(String baseName, IItemTier material, int damage, float speed) {
|
2019-11-04 19:08:49 +01:00
|
|
|
super(material, damage, speed, new Properties().group(NaturesAura.CREATIVE_TAB));
|
2018-10-19 18:32:20 +02:00
|
|
|
this.baseName = baseName;
|
2020-01-22 01:32:26 +01:00
|
|
|
ModRegistry.add(this);
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBaseName() {
|
|
|
|
return this.baseName;
|
|
|
|
}
|
|
|
|
|
2018-11-13 19:15:24 +01:00
|
|
|
@Override
|
2019-10-20 22:30:49 +02:00
|
|
|
public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
2020-05-13 15:52:46 +02:00
|
|
|
if (this == ModItems.INFUSED_IRON_SWORD) {
|
2019-10-20 22:30:49 +02:00
|
|
|
target.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 60, 2));
|
2020-05-13 15:52:46 +02:00
|
|
|
} else if (this == ModItems.SKY_SWORD) {
|
|
|
|
target.addPotionEffect(new EffectInstance(Effects.LEVITATION, 60, 2));
|
|
|
|
}
|
2018-11-13 19:15:24 +01:00
|
|
|
return super.hitEntity(stack, target, attacker);
|
|
|
|
}
|
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
@Nullable
|
|
|
|
@Override
|
2019-10-20 22:30:49 +02:00
|
|
|
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
|
2020-05-13 15:52:46 +02:00
|
|
|
return Helper.makeRechargeProvider(stack, true);
|
2018-10-20 21:19:08 +02:00
|
|
|
}
|
2020-01-29 00:40:28 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
|
|
|
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
|
|
|
}
|
|
|
|
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|