Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: Class that defines my projectile's behavior
Submitted on February 12, 2024 at 07:30 AM
Expires on February 11, 2025 at 07:30 AM (8 months from now)

package net.raguraccoon.ragu_testin.entity.custom;

import net.minecraft.client.Minecraft;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractHurtingProjectile;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraftforge.network.NetworkHooks;

public class IncinerateBall extends AbstractHurtingProjectile {

    private int life = 0;
    public IncinerateBall(EntityType<IncinerateBall> entityType, Level level) {
        super(entityType, level);
    }   

    public IncinerateBall(EntityType<IncinerateBall> entityType, double x, double y, double z, double x1, double y1, double z1, Level level) {
        super(entityType, x, y, z, x1, y1, z1, level);
    }

    public IncinerateBall(EntityType<IncinerateBall> entityType, LivingEntity livingEntity, double x, double y, double z, Level level) {
        super(entityType, livingEntity, x, y, z, level);
    }


    @Override
    public void onHitEntity(EntityHitResult entityHitResult) {
        if (!this.level.isClientSide()) {
            Minecraft.getInstance().player.sendSystemMessage(Component.literal("Hit Entity"));
            super.onHitEntity(entityHitResult);
            Entity entity = entityHitResult.getEntity();
            entity.hurt(DamageSource.LAVA, 5f);
        }
    }

    @Override
    protected void onHitBlock(BlockHitResult blockHitResult) {
        if (!this.level.isClientSide()) {
            super.onHitBlock(blockHitResult);
            Minecraft.getInstance().player.sendSystemMessage(Component.literal("Hit Block"));
        }
    }

    @Override
    protected void onHit(HitResult hitResult) {
        if (!this.level.isClientSide()) {
            Minecraft.getInstance().player.sendSystemMessage(Component.literal("Hit"));
            super.onHit(hitResult);
        }
    }

    @Override
    public boolean isPickable() {
        return false;
    }

    @Override
    public Packet<?> getAddEntityPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }

    @Override
    public ParticleOptions getTrailParticle() {
        return ParticleTypes.BUBBLE;
    }

    @Override
    public boolean isOnFire() {
        return false;
    }

    @Override
    public void tick() {
        super.tick();
        ++this.life;
        if (this.life >= 30) {
            this.remove(RemovalReason.DISCARDED);
        }
    }

    @Override
    public boolean hurt(DamageSource damageSource, float v) {
        return false;
    }
}