Search in sources :

Example 1 with PacketRemove

use of ebf.tim.networking.PacketRemove in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class GenericRailTransport method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_) {
    //if its a creative player, destroy instantly
    if (damageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer) damageSource.getEntity()).capabilities.isCreativeMode && !damageSource.isProjectile()) {
        health -= 20;
    //if its reinforced and its not an explosion
    } else if (isReinforced() && !damageSource.isProjectile() && !damageSource.isExplosion()) {
        health -= 1;
    //if it is an explosion and it's reinforced, or it's not an explosion and isn't reinforced
    } else if ((damageSource.isExplosion() && isReinforced()) || (!isReinforced() && !damageSource.isProjectile())) {
        health -= 5;
    //if it isn't reinforced and is an explosion
    } else if (damageSource.isExplosion() && !isReinforced()) {
        health -= 20;
    }
    //cover overheating, or other damage to self.
    if (damageSource.getSourceOfDamage() == this) {
        health -= 20;
    }
    //on Destruction
    if (health < 1) {
        //remove bogies
        frontBogie.isDead = true;
        TrainsInMotion.keyChannel.sendToServer(new PacketRemove(frontBogie.getEntityId()));
        worldObj.removeEntity(frontBogie);
        backBogie.isDead = true;
        TrainsInMotion.keyChannel.sendToServer(new PacketRemove(backBogie.getEntityId()));
        worldObj.removeEntity(backBogie);
        //remove seats
        for (EntitySeat seat : seats) {
            seat.isDead = true;
            TrainsInMotion.keyChannel.sendToServer(new PacketRemove(seat.getEntityId()));
            seat.worldObj.removeEntity(seat);
        }
        //remove hitboxes
        for (EntityDragonPart hitbox : hitboxHandler.hitboxList) {
            hitbox.isDead = true;
            TrainsInMotion.keyChannel.sendToServer(new PacketRemove(hitbox.getEntityId()));
            hitbox.worldObj.removeEntity(hitbox);
        }
        //if the damage source is an explosion, or this (from overheating as an example), we circumstantially blow up.
        //radius is defined by whether or not it's a nuclear train, and fire spread creation is defined by whether or not it's diesel.
        //remove this
        isDead = true;
        TrainsInMotion.keyChannel.sendToServer(new PacketRemove(getEntityId()));
        worldObj.removeEntity(this);
    }
    return false;
}
Also used : EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketRemove(ebf.tim.networking.PacketRemove)

Aggregations

PacketRemove (ebf.tim.networking.PacketRemove)1 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1