package net.tropicraft.core.common.entity.projectile;_x000D_
_x000D_
import net.minecraft.core.BlockPos;_x000D_
import net.minecraft.core.particles.ParticleTypes;_x000D_
import net.minecraft.nbt.CompoundTag;_x000D_
import net.minecraft.network.protocol.Packet;_x000D_
import net.minecraft.network.protocol.game.ClientGamePacketListener;_x000D_
import net.minecraft.world.entity.Entity;_x000D_
import net.minecraft.world.entity.EntityType;_x000D_
import net.minecraft.world.entity.MoverType;_x000D_
import net.minecraft.world.level.Level;_x000D_
import net.minecraft.world.level.block.Blocks;_x000D_
import net.minecraft.world.level.block.state.BlockState;_x000D_
import net.minecraft.world.phys.Vec3;_x000D_
import net.minecraftforge.api.distmarker.Dist;_x000D_
import net.minecraftforge.api.distmarker.OnlyIn;_x000D_
import net.minecraftforge.network.NetworkHooks;_x000D_
_x000D_
public class LavaBallEntity extends Entity {_x000D_
    public boolean setFire;_x000D_
    public float size;_x000D_
    public boolean held;_x000D_
    public int lifeTimer;_x000D_
_x000D_
    public double accelerationX;_x000D_
    public double accelerationY;_x000D_
    public double accelerationZ;_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type, Level world) {_x000D_
        super(type, world);_x000D_
        setFire = false;_x000D_
        held = false;_x000D_
        size = 1;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type,Level world, double i, double j, double k, double motX, double motY, double motZ) {_x000D_
        super(type, world);_x000D_
        setFire = false;_x000D_
        moveTo(i, j, k, 0, 0);_x000D_
        accelerationX = motX;_x000D_
        accelerationY = motY;_x000D_
        accelerationZ = motZ;_x000D_
        size = 1;_x000D_
        held = false;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type, Level world, float startSize) {_x000D_
        super(type, world);_x000D_
        size = startSize;_x000D_
        setFire = false;_x000D_
        held = true;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public boolean isPickable() {_x000D_
        return true;_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public boolean isPushable() {_x000D_
        return true;_x000D_
    }_x000D_
_x000D_
    @OnlyIn(Dist.CLIENT)_x000D_
    public void supahDrip() {_x000D_
        float x = (float) getX();_x000D_
        float y = (float) getY();_x000D_
        float z = (float) getZ();_x000D_
_x000D_
        if (level().isClientSide) {_x000D_
            level().addParticle(ParticleTypes.LAVA, x, y, z, this.getDeltaMovement().x, -1.5F, this.getDeltaMovement().z);_x000D_
        }_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    protected void defineSynchedData() {_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public void tick() {_x000D_
        super.tick();_x000D_
        // System.out.println("laba ball: " + posX + " " + posY + " " + posZ);_x000D_
_x000D_
        if (lifeTimer < 500) {_x000D_
            lifeTimer++;_x000D_
        } else {_x000D_
            this.remove(RemovalReason.DISCARDED);_x000D_
        }_x000D_
_x000D_
        double motionX = this.getDeltaMovement().x;_x000D_
        double motionY = this.getDeltaMovement().y;_x000D_
        double motionZ = this.getDeltaMovement().z;_x000D_
_x000D_
        if (size < 1) {_x000D_
            size += .025;_x000D_
        }_x000D_
_x000D_
        if (onGround()) {_x000D_
            motionZ *= .95;_x000D_
            motionX *= .95;_x000D_
        }_x000D_
_x000D_
        motionY *= .99;_x000D_
_x000D_
        if (!onGround()) {_x000D_
            motionY -=.05F;_x000D_
            if (level().isClientSide) {_x000D_
                for (int i = 0; i < 5 + random.nextInt(3); i++){_x000D_
                    supahDrip();_x000D_
                }_x000D_
            }_x000D_
        }_x000D_
_x000D_
        if (horizontalCollision) {_x000D_
            motionZ = 0;_x000D_
            motionX = 0;_x000D_
        }_x000D_
_x000D_
        //TODO: Note below, these used to be tempLavaMoving - maybe they still need to be?_x000D_
        int thisX = (int)Math.floor(getX());_x000D_
        int thisY = (int)Math.floor(getY());_x000D_
        int thisZ = (int)Math.floor(getZ());_x000D_
_x000D_
        BlockPos posCurrent = new BlockPos(thisX, thisY, thisZ);_x000D_
        BlockPos posBelow = posCurrent.below();_x000D_
        BlockState stateBelow = level().getBlockState(posBelow);_x000D_
_x000D_
        if (!stateBelow.isAir() && !stateBelow.is(Blocks.LAVA) && !held) {_x000D_
            if (setFire) {_x000D_
                level().setBlock(posCurrent, Blocks.LAVA.defaultBlockState(), 3);_x000D_
                this.remove(RemovalReason.DISCARDED);_x000D_
            }_x000D_
_x000D_
            if (!setFire) {_x000D_
                if (level().isEmptyBlock(posCurrent.west())) {_x000D_
                    level().setBlock(posCurrent.west(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.east())) {_x000D_
                    level().setBlock(posCurrent.east(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.south())) {_x000D_
                    level().setBlock(posCurrent.south(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.north())) {_x000D_
                    level().setBlock(posCurrent.north(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                level().setBlock(posCurrent, Blocks.LAVA.defaultBlockState(), 3);_x000D_
                setFire = true;_x000D_
            }_x000D_
        }_x000D_
_x000D_
        Vec3 motion = new Vec3(motionX + this.accelerationX, motionY + this.accelerationY, motionZ + this.accelerationZ);_x000D_
        this.setDeltaMovement(motion);_x000D_
_x000D_
        this.move(MoverType.SELF, motion);_x000D_
    }_x000D_
_x000D_
    // TODO: Need this again? 1.14_x000D_
    /*@Override_x000D_
    protected void entityInit() {_x000D_
_x000D_
    }*/_x000D_
_x000D_
    @Override_x000D_
    protected void readAdditionalSaveData(CompoundTag nbt) {_x000D_
        this.lifeTimer = nbt.getInt("lifeTimer");_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    protected void addAdditionalSaveData(CompoundTag nbt) {_x000D_
        nbt.putInt("lifeTimer", this.lifeTimer);_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public Packet<ClientGamePacketListener> getAddEntityPacket() {_x000D_
        return NetworkHooks.getEntitySpawningPacket(this);_x000D_
    }_x000D_
_x000D_
}_x000D_

/*@Override_x000D_
    protected void entityInit() {_x000D_
_x000D_
    }*/
package net.tropicraft.core.common.entity.projectile;_x000D_
_x000D_
import net.minecraft.core.BlockPos;_x000D_
import net.minecraft.core.particles.ParticleTypes;_x000D_
import net.minecraft.nbt.CompoundTag;_x000D_
import net.minecraft.network.protocol.Packet;_x000D_
import net.minecraft.network.protocol.game.ClientGamePacketListener;_x000D_
import net.minecraft.world.entity.Entity;_x000D_
import net.minecraft.world.entity.EntityType;_x000D_
import net.minecraft.world.entity.MoverType;_x000D_
import net.minecraft.world.level.Level;_x000D_
import net.minecraft.world.level.block.Blocks;_x000D_
import net.minecraft.world.level.block.state.BlockState;_x000D_
import net.minecraft.world.phys.Vec3;_x000D_
import net.minecraftforge.api.distmarker.Dist;_x000D_
import net.minecraftforge.api.distmarker.OnlyIn;_x000D_
import net.minecraftforge.network.NetworkHooks;_x000D_
_x000D_
public class LavaBallEntity extends Entity {_x000D_
    public boolean setFire;_x000D_
    public float size;_x000D_
    public boolean held;_x000D_
    public int lifeTimer;_x000D_
_x000D_
    public double accelerationX;_x000D_
    public double accelerationY;_x000D_
    public double accelerationZ;_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type, Level world) {_x000D_
        super(type, world);_x000D_
        setFire = false;_x000D_
        held = false;_x000D_
        size = 1;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type,Level world, double i, double j, double k, double motX, double motY, double motZ) {_x000D_
        super(type, world);_x000D_
        setFire = false;_x000D_
        moveTo(i, j, k, 0, 0);_x000D_
        accelerationX = motX;_x000D_
        accelerationY = motY;_x000D_
        accelerationZ = motZ;_x000D_
        size = 1;_x000D_
        held = false;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    public LavaBallEntity(EntityType<? extends LavaBallEntity> type, Level world, float startSize) {_x000D_
        super(type, world);_x000D_
        size = startSize;_x000D_
        setFire = false;_x000D_
        held = true;_x000D_
        lifeTimer = 0;_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public boolean isPickable() {_x000D_
        return true;_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public boolean isPushable() {_x000D_
        return true;_x000D_
    }_x000D_
_x000D_
    @OnlyIn(Dist.CLIENT)_x000D_
    public void supahDrip() {_x000D_
        float x = (float) getX();_x000D_
        float y = (float) getY();_x000D_
        float z = (float) getZ();_x000D_
_x000D_
        if (level().isClientSide) {_x000D_
            level().addParticle(ParticleTypes.LAVA, x, y, z, this.getDeltaMovement().x, -1.5F, this.getDeltaMovement().z);_x000D_
        }_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    protected void defineSynchedData() {_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public void tick() {_x000D_
        super.tick();_x000D_
        // System.out.println("laba ball: " + posX + " " + posY + " " + posZ);_x000D_
_x000D_
        if (lifeTimer < 500) {_x000D_
            lifeTimer++;_x000D_
        } else {_x000D_
            this.remove(RemovalReason.DISCARDED);_x000D_
        }_x000D_
_x000D_
        double motionX = this.getDeltaMovement().x;_x000D_
        double motionY = this.getDeltaMovement().y;_x000D_
        double motionZ = this.getDeltaMovement().z;_x000D_
_x000D_
        if (size < 1) {_x000D_
            size += .025;_x000D_
        }_x000D_
_x000D_
        if (onGround()) {_x000D_
            motionZ *= .95;_x000D_
            motionX *= .95;_x000D_
        }_x000D_
_x000D_
        motionY *= .99;_x000D_
_x000D_
        if (!onGround()) {_x000D_
            motionY -=.05F;_x000D_
            if (level().isClientSide) {_x000D_
                for (int i = 0; i < 5 + random.nextInt(3); i++){_x000D_
                    supahDrip();_x000D_
                }_x000D_
            }_x000D_
        }_x000D_
_x000D_
        if (horizontalCollision) {_x000D_
            motionZ = 0;_x000D_
            motionX = 0;_x000D_
        }_x000D_
_x000D_
        //TODO: Note below, these used to be tempLavaMoving - maybe they still need to be?_x000D_
        int thisX = (int)Math.floor(getX());_x000D_
        int thisY = (int)Math.floor(getY());_x000D_
        int thisZ = (int)Math.floor(getZ());_x000D_
_x000D_
        BlockPos posCurrent = new BlockPos(thisX, thisY, thisZ);_x000D_
        BlockPos posBelow = posCurrent.below();_x000D_
        BlockState stateBelow = level().getBlockState(posBelow);_x000D_
_x000D_
        if (!stateBelow.isAir() && !stateBelow.is(Blocks.LAVA) && !held) {_x000D_
            if (setFire) {_x000D_
                level().setBlock(posCurrent, Blocks.LAVA.defaultBlockState(), 3);_x000D_
                this.remove(RemovalReason.DISCARDED);_x000D_
            }_x000D_
_x000D_
            if (!setFire) {_x000D_
                if (level().isEmptyBlock(posCurrent.west())) {_x000D_
                    level().setBlock(posCurrent.west(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.east())) {_x000D_
                    level().setBlock(posCurrent.east(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.south())) {_x000D_
                    level().setBlock(posCurrent.south(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                if (level().isEmptyBlock(posCurrent.north())) {_x000D_
                    level().setBlock(posCurrent.north(), Blocks.LAVA.defaultBlockState(), 2);_x000D_
                }_x000D_
_x000D_
                level().setBlock(posCurrent, Blocks.LAVA.defaultBlockState(), 3);_x000D_
                setFire = true;_x000D_
            }_x000D_
        }_x000D_
_x000D_
        Vec3 motion = new Vec3(motionX + this.accelerationX, motionY + this.accelerationY, motionZ + this.accelerationZ);_x000D_
        this.setDeltaMovement(motion);_x000D_
_x000D_
        this.move(MoverType.SELF, motion);_x000D_
    }_x000D_
_x000D_
    // TODO: Need this again? 1.14_x000D_
    /*@Override_x000D_
 <SUF>*/_x000D_
_x000D_
    @Override_x000D_
    protected void readAdditionalSaveData(CompoundTag nbt) {_x000D_
        this.lifeTimer = nbt.getInt("lifeTimer");_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    protected void addAdditionalSaveData(CompoundTag nbt) {_x000D_
        nbt.putInt("lifeTimer", this.lifeTimer);_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public Packet<ClientGamePacketListener> getAddEntityPacket() {_x000D_
        return NetworkHooks.getEntitySpawningPacket(this);_x000D_
    }_x000D_
_x000D_
}_x000D_
