Search in sources :

Example 1 with IItemFrequency

use of com.builtbroken.mc.api.items.hz.IItemFrequency in project ICBM-Classic by BuiltBrokenModding.

the class TileRadarStation method doScan.

private void doScan() {
    this.incomingMissiles.clear();
    this.detectedEntities.clear();
    List<Entity> entities = RadarRegistry.getAllLivingObjectsWithin(world(), xi() + 1.5, yi() + 0.5, zi() + 0.5, MAX_DETECTION_RANGE, null);
    for (Entity entity : entities) {
        if (entity instanceof EntityMissile) {
            if (((EntityMissile) entity).getTicksInAir() > -1) {
                if (!this.detectedEntities.contains(entity)) {
                    this.detectedEntities.add(entity);
                }
                if (this.isMissileGoingToHit((EntityMissile) entity)) {
                    if (this.incomingMissiles.size() > 0) {
                        /** Sort in order of distance */
                        double dist = new Pos((TileEntity) this).distance(new Pos(entity));
                        for (int i = 0; i < this.incomingMissiles.size(); i++) {
                            EntityMissile daoDan = this.incomingMissiles.get(i);
                            if (dist < new Pos((TileEntity) this).distance(daoDan.toPos())) {
                                this.incomingMissiles.add(i, (EntityMissile) entity);
                                break;
                            } else if (i == this.incomingMissiles.size() - 1) {
                                this.incomingMissiles.add((EntityMissile) entity);
                                break;
                            }
                        }
                    } else {
                        this.incomingMissiles.add((EntityMissile) entity);
                    }
                }
            }
        } else {
            this.detectedEntities.add(entity);
        }
    }
    List<EntityPlayer> players = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord - MAX_DETECTION_RANGE, this.yCoord - MAX_DETECTION_RANGE, this.zCoord - MAX_DETECTION_RANGE, this.xCoord + MAX_DETECTION_RANGE, this.yCoord + MAX_DETECTION_RANGE, this.zCoord + MAX_DETECTION_RANGE));
    for (EntityPlayer player : players) {
        if (player != null) {
            boolean youHuoLuan = false;
            for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
                ItemStack itemStack = player.inventory.getStackInSlot(i);
                if (itemStack != null) {
                    if (itemStack.getItem() instanceof IItemFrequency) {
                        youHuoLuan = true;
                        break;
                    }
                }
            }
            if (!youHuoLuan) {
                this.detectedEntities.add(player);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityMissile(icbm.classic.content.entity.EntityMissile) Point(com.builtbroken.mc.imp.transform.vector.Point) IItemFrequency(com.builtbroken.mc.api.items.hz.IItemFrequency)

Example 2 with IItemFrequency

use of com.builtbroken.mc.api.items.hz.IItemFrequency in project ICBM-Classic by BuiltBrokenModding.

the class GuiFrequency method initGui.

/** Adds the buttons (and other controls) to the screen in question. */
@Override
public void initGui() {
    super.initGui();
    this.textFieldFrequency = new GuiTextField(fontRendererObj, 80, 50, 40, 12);
    this.textFieldFrequency.setMaxStringLength(4);
    if (itemStack != null) {
        this.textFieldFrequency.setText(((IItemFrequency) this.itemStack.getItem()).getBroadCastHz(this.itemStack) + "");
    }
}
Also used : GuiTextField(net.minecraft.client.gui.GuiTextField) IItemFrequency(com.builtbroken.mc.api.items.hz.IItemFrequency)

Aggregations

IItemFrequency (com.builtbroken.mc.api.items.hz.IItemFrequency)2 Point (com.builtbroken.mc.imp.transform.vector.Point)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 EntityMissile (icbm.classic.content.entity.EntityMissile)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1