Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class AbstractStaffItem extends TieredItem implements IVanishable {
- private final Multimap<Attribute, AttributeModifier> attributeModifiers;
- private Entity projectile;
- private String staffName;
- private SoundEvent castSpell;
- private SoundEvent castSpellEmpty;
- private int xpAmount = 1;
- private double damage = 1.0D;
- private float velocity;
- private float innacuracy = 1.0F;
- public AbstractStaffItem(IItemTier tierIn, float attackSpeedIn, Properties properties) {
- super(tierIn, properties);
- ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
- builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)attackSpeedIn, AttributeModifier.Operation.ADDITION));
- this.attributeModifiers = builder.build();
- }
- @Override
- public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
- if (entityLiving instanceof PlayerEntity)
- LeftClickEvent.onLeftClickStaffWand((PlayerEntity) entityLiving, stack);
- return super.onItemUseFinish(stack, worldIn, entityLiving);
- }
- public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
- return !player.isCreative();
- }
- public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
- stack.damageItem(2, attacker, (entity) -> {
- entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
- });
- return true;
- }
- public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) {
- if (state.getBlockHardness(worldIn, pos) != 0.0F) {
- stack.damageItem(2, entityLiving, (entity) -> {
- entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
- });
- }
- return true;
- }
- public void setXpAmount(int xpIn) { this.xpAmount = xpIn; }
- public int getXpAmount() { return this.xpAmount; }
- public void setDamage(double damageIn) { this.damage = damageIn; }
- public double getDamage() {
- return this.damage;
- }
- public void setVelocity(float velocityIn) { this.velocity = velocityIn; }
- public float getVelocity() {
- return this.velocity;
- }
- public void setInnacuracy(float innacuracyIn) { this.innacuracy = innacuracyIn; }
- public float getInnacuracy() {
- return this.innacuracy;
- }
- public void setSpellSound(SoundEvent spellSoundIn) { this.castSpell = spellSoundIn; }
- public SoundEvent getSpellSound() { return this.castSpell; }
- public void setEmptySound(SoundEvent emptySoundIn) { this.castSpellEmpty = emptySoundIn; }
- public SoundEvent getEmptySound() { return this.castSpellEmpty; }
- public Entity getProjectile(LivingEntity shooter, ItemStack stack) { return this.projectile; }
- public void setStaffName(String nameIn) { this.staffName = nameIn; }
- public String getStaffName() { return this.staffName; }
- @OnlyIn(Dist.CLIENT)
- public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
- super.addInformation(stack, worldIn, tooltip, flagIn);
- tooltip.add((new TranslationTextComponent("Damage: " + this.getDamage())).mergeStyle(TextFormatting.BLUE));
- tooltip.add((new TranslationTextComponent("XP Cost: " + this.getXpAmount())).mergeStyle(TextFormatting.BLUE));
- }
- @SuppressWarnings("deprecation")
- @Override
- public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType equipmentSlot) {
- return equipmentSlot == EquipmentSlotType.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(equipmentSlot);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement