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;
|
|
|
|
import de.ellpeck.naturesaura.items.ModItems;
|
2018-11-29 17:58:47 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ICreativeItem;
|
2018-10-19 18:32:20 +02:00
|
|
|
import de.ellpeck.naturesaura.reg.IModItem;
|
|
|
|
import de.ellpeck.naturesaura.reg.IModelProvider;
|
|
|
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
import net.minecraft.potion.Effects;
|
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;
|
2018-10-20 21:19:08 +02:00
|
|
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
2018-10-19 18:32:20 +02:00
|
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2019-10-20 22:30:49 +02:00
|
|
|
public class ItemSwordNA extends SwordItem implements IModItem, ICreativeItem, IModelProvider {
|
2018-10-19 18:32:20 +02:00
|
|
|
private final String baseName;
|
|
|
|
|
|
|
|
public ItemSwordNA(String baseName, ToolMaterial material) {
|
|
|
|
super(material);
|
|
|
|
this.baseName = baseName;
|
2018-11-29 17:58:47 +01:00
|
|
|
ModRegistry.add(this);
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBaseName() {
|
|
|
|
return this.baseName;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPreInit(FMLPreInitializationEvent event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInit(FMLInitializationEvent event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPostInit(FMLPostInitializationEvent event) {
|
|
|
|
|
|
|
|
}
|
2018-10-20 21:19:08 +02:00
|
|
|
|
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) {
|
2018-11-13 19:15:24 +01:00
|
|
|
if (this == ModItems.INFUSED_SWORD)
|
2019-10-20 22:30:49 +02:00
|
|
|
target.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 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) {
|
2018-10-20 21:19:08 +02:00
|
|
|
if (this == ModItems.INFUSED_SWORD)
|
2018-12-01 18:56:05 +01:00
|
|
|
return Helper.makeRechargeProvider(stack, true);
|
2018-10-20 21:19:08 +02:00
|
|
|
else return null;
|
|
|
|
}
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|