Advertisement
Guest User

Untitled

a guest
May 8th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. public abstract class AbstractStaffItem extends TieredItem implements IVanishable {
  2. private final Multimap<Attribute, AttributeModifier> attributeModifiers;
  3.  
  4. private Entity projectile;
  5. private String staffName;
  6. private SoundEvent castSpell;
  7. private SoundEvent castSpellEmpty;
  8. private int xpAmount = 1;
  9. private double damage = 1.0D;
  10. private float velocity;
  11. private float innacuracy = 1.0F;
  12.  
  13. public AbstractStaffItem(IItemTier tierIn, float attackSpeedIn, Properties properties) {
  14. super(tierIn, properties);
  15. ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
  16. builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)attackSpeedIn, AttributeModifier.Operation.ADDITION));
  17. this.attributeModifiers = builder.build();
  18.  
  19. }
  20.  
  21. @Override
  22. public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
  23. if (entityLiving instanceof PlayerEntity)
  24. LeftClickEvent.onLeftClickStaffWand((PlayerEntity) entityLiving, stack);
  25.  
  26. return super.onItemUseFinish(stack, worldIn, entityLiving);
  27. }
  28. public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
  29. return !player.isCreative();
  30. }
  31. public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
  32. stack.damageItem(2, attacker, (entity) -> {
  33. entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
  34. });
  35. return true;
  36. }
  37. public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) {
  38. if (state.getBlockHardness(worldIn, pos) != 0.0F) {
  39. stack.damageItem(2, entityLiving, (entity) -> {
  40. entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
  41. });
  42. }
  43. return true;
  44. }
  45. public void setXpAmount(int xpIn) { this.xpAmount = xpIn; }
  46. public int getXpAmount() { return this.xpAmount; }
  47. public void setDamage(double damageIn) { this.damage = damageIn; }
  48. public double getDamage() {
  49. return this.damage;
  50. }
  51. public void setVelocity(float velocityIn) { this.velocity = velocityIn; }
  52. public float getVelocity() {
  53. return this.velocity;
  54. }
  55. public void setInnacuracy(float innacuracyIn) { this.innacuracy = innacuracyIn; }
  56. public float getInnacuracy() {
  57. return this.innacuracy;
  58. }
  59. public void setSpellSound(SoundEvent spellSoundIn) { this.castSpell = spellSoundIn; }
  60. public SoundEvent getSpellSound() { return this.castSpell; }
  61. public void setEmptySound(SoundEvent emptySoundIn) { this.castSpellEmpty = emptySoundIn; }
  62. public SoundEvent getEmptySound() { return this.castSpellEmpty; }
  63. public Entity getProjectile(LivingEntity shooter, ItemStack stack) { return this.projectile; }
  64. public void setStaffName(String nameIn) { this.staffName = nameIn; }
  65. public String getStaffName() { return this.staffName; }
  66.  
  67. @OnlyIn(Dist.CLIENT)
  68. public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
  69. super.addInformation(stack, worldIn, tooltip, flagIn);
  70.  
  71. tooltip.add((new TranslationTextComponent("Damage: " + this.getDamage())).mergeStyle(TextFormatting.BLUE));
  72. tooltip.add((new TranslationTextComponent("XP Cost: " + this.getXpAmount())).mergeStyle(TextFormatting.BLUE));
  73. }
  74. @SuppressWarnings("deprecation")
  75. @Override
  76. public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType equipmentSlot) {
  77. return equipmentSlot == EquipmentSlotType.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(equipmentSlot);
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement