This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
SlightlyVanilla/src/main/java/com/thebrokenrail/slightlyvanilla/entity/SlimeballEntity.java

71 lines
2.1 KiB
Java
Raw Normal View History

2020-03-19 19:45:46 +00:00
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;
2020-03-22 17:54:49 +00:00
@SuppressWarnings("unused")
2020-03-19 19:45:46 +00:00
public class SlimeballEntity extends ThrownItemEntity {
public SlimeballEntity(EntityType<SlimeballEntity> 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);
}
2020-03-22 17:54:49 +00:00
public SlimeballEntity(World world) {
super(SlightlyVanilla.SLIMEBALL_ENTITY, world);
}
2020-03-21 16:35:09 +00:00
@Override
2020-03-19 19:45:46 +00:00
protected Item getDefaultItem() {
return Items.SLIME_BALL;
}
@Environment(EnvType.CLIENT)
private ParticleEffect getParticleParameters() {
return ParticleTypes.ITEM_SLIME;
2020-03-19 19:45:46 +00:00
}
@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);
}
}
}
2020-03-21 16:35:09 +00:00
@Override
2020-03-19 19:45:46 +00:00
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);
}
}