Search in sources :

Example 1 with ItemTracker

use of icbm.classic.content.items.ItemTracker in project ICBM-Classic by BuiltBrokenModding.

the class MissileHoming method onInteract.

@Override
public boolean onInteract(EntityMissile missileObj, EntityPlayer entityPlayer) {
    if (!missileObj.worldObj.isRemote && missileObj.getTicksInAir() <= 0) {
        if (entityPlayer.getCurrentEquippedItem() != null) {
            if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemTracker) {
                Entity trackingEntity = ((ItemTracker) entityPlayer.getCurrentEquippedItem().getItem()).getTrackingEntity(missileObj.worldObj, entityPlayer.getCurrentEquippedItem());
                if (trackingEntity != null) {
                    if (missileObj.trackingVar != trackingEntity.getEntityId()) {
                        missileObj.trackingVar = trackingEntity.getEntityId();
                        entityPlayer.addChatMessage(new ChatComponentText("Missile target locked to: " + trackingEntity.getCommandSenderName()));
                        if (missileObj.getLauncher() != null && missileObj.getLauncher().getController() != null) {
                            Pos newTarget = new Pos(trackingEntity.posX, 0, trackingEntity.posZ);
                            missileObj.getLauncher().getController().setTarget(newTarget);
                        }
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) ItemTracker(icbm.classic.content.items.ItemTracker) Pos(com.builtbroken.mc.imp.transform.vector.Pos) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 ItemTracker (icbm.classic.content.items.ItemTracker)1 Entity (net.minecraft.entity.Entity)1 ChatComponentText (net.minecraft.util.ChatComponentText)1