package com.thebrokenrail.slightlyvanilla.entity; import com.thebrokenrail.slightlyvanilla.SlightlyVanilla; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.thrown.ThrownItemEntity; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.network.Packet; import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.hit.HitResult; import net.minecraft.world.World; @SuppressWarnings("unused") public class SlimeballEntity extends ThrownItemEntity { public SlimeballEntity(EntityType entityType, World world) { super(entityType, world); } public SlimeballEntity(World world, LivingEntity owner) { super(SlightlyVanilla.SLIMEBALL_ENTITY, owner, world); } public SlimeballEntity(World world, double x, double y, double z) { super(SlightlyVanilla.SLIMEBALL_ENTITY, x, y, z, world); } public SlimeballEntity(World world) { super(SlightlyVanilla.SLIMEBALL_ENTITY, world); } @Override protected Item getDefaultItem() { return Items.SLIME_BALL; } @Environment(EnvType.CLIENT) private ParticleEffect getParticleParameters() { return ParticleTypes.ITEM_SLIME; } @Environment(EnvType.CLIENT) public void handleStatus(byte status) { if (status == 3) { ParticleEffect particleEffect = getParticleParameters(); for (int i = 0; i < 8; ++i) { world.addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D); } } } @Override protected void onCollision(HitResult hitResult) { super.onCollision(hitResult); if (!world.isClient()) { world.sendEntityStatus(this, (byte) 3); remove(); } } @Override public Packet createSpawnPacket() { return new EntitySpawnS2CPacket(this); } }