Jump to content

Will6

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Will6

  1. What is the best way to make a splash potion drop on the ground upon right clicking with a custom item? I overrode use but I'm not quite sure about how to get the splash potion to drop. import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.projectile.ThrowableProjectile; import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.*; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import java.util.Objects; public class TitaniumLongswordItem extends SwordItem { private static Properties properties = new Item.Properties().tab(CreativeModeTab.TAB_COMBAT); public static Item INSTANCE = new TitaniumLongswordItem(Tiers.IRON, 17, 2147483646, properties).setRegistryName(BaseMod.MODID,"titaniumlongsword"); public TitaniumLongswordItem(Tier tier, int attackDamageIn, float attackSpeedIn, Properties properties) { super(tier, attackDamageIn, attackSpeedIn, properties); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player playerIn, InteractionHand handIn){ ItemStack itemstack = playerIn.getItemInHand(handIn); BlockPos location = Utils.getBlockAtCursor(playerIn, 20.0d, true); Entity entity = new ThrownPotion(EntityType.POTION);// new MobEffectInstance(MobEffects.HARM); //float explosionRadius = 0f; if(location != null){ //Utils.strikeLightning(level, location); //Utils.createExplosion(level, location, explosionRadius); Utils.spawnEntity(level, entity, location); } BlockPos blockPos = Utils.getBlockAtCursor(playerIn, 20.0d, true); if(blockPos != null){ playerIn.teleportTo(blockPos.getX(), blockPos.getY()+1, blockPos.getZ()); playerIn.fallDistance = 2.0F; playerIn.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 50, 150)); playerIn.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 400, 2)); return InteractionResultHolder.pass(itemstack); } return InteractionResultHolder.pass(itemstack); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.