コード例 #1
0
 @Override
 public void updateValues(EntityClone clone) {
   lastBuild = clone.getBuildAI().isRunning();
   lastBuildState = clone.getBuildAI().getBuildState();
   lastFullSize = clone.getBuildAI().getSchemFullSize();
   isDirty = false;
 }
コード例 #2
0
  @Override
  public void initGui() {
    initGuiComponents();

    nameBox =
        new GuiTextField(mc.fontRenderer, spacing, 80 + spacing, width - spacing * 2, buttonHeight);
    nameBox.setText(clone.getFullEditedName());
    lastTickName = clone.getFullEditedName();
    Keyboard.enableRepeatEvents(true);
  }
コード例 #3
0
 @Override
 public void updateScreen() {
   if (!lastTickName.equals(nameBox.getText())) {
     lastTickName = nameBox.getText();
     clone.setName(lastTickName);
     clone.getSyncer().sendValueToServer(Syncer.ID_NAME);
   } else if (!nameBox.isFocused() && !nameBox.getText().equals(clone.nameUnedited)) {
     nameBox.setText(clone.nameUnedited);
   }
   nameBox.updateCursorCounter();
 }
コード例 #4
0
 @Override
 public void read(DataInputStream in, EntityClone clone) throws IOException {
   if (clone.worldObj.isRemote) {
     clone.getBuildAI().setBuilding(in.readBoolean());
     clone.getBuildAI().setSchemFullSize(in.readInt());
     clone.getBuildAI().setBuildState(in.read());
   } else {
     clone.getBuildAI().setBuilding(in.readBoolean());
     in.readInt();
     in.read();
   }
 }
コード例 #5
0
  @Override
  public boolean checkNeedsUpdating(EntityClone clone) {
    EntityAIBuild ai = clone.getBuildAI();

    return isDirty
        || ai.isRunning() != lastBuild
        || ai.getBuildState() != lastBuildState
        || ai.getSchemFullSize() != lastFullSize;
  }
コード例 #6
0
ファイル: Unbreakables.java プロジェクト: Jamezo97/CloneCraft
  public void pickedUp(EntityClone clone, ItemStack stack) {
    for (int a = 0; a < entries.size(); a++) {
      UnbreakableEntry entry = entries.get(a);

      if (clone.canItemHarvestBlock(stack, entry.coordinates, entry.block, entry.meta)) {
        entries.remove(a);
        a--;
      }
    }
  }
コード例 #7
0
ファイル: Unbreakables.java プロジェクト: Jamezo97/CloneCraft
  public void checkUnbreakables(EntityClone clone, double posX, double posY, double posZ) {
    for (int a = 0; a < entries.size(); a++) {
      UnbreakableEntry entry = entries.get(a);

      if (entry.getDistSq(posX, posY, posZ) < 1024) {
        if (!entry.isSameBlock(clone.worldObj)) {
          entries.remove(a--);
          continue;
        } else {
          if (clone.selectBestItemForBlock(entry.coordinates, entry.block, entry.meta, false)) {
            entries.remove(a--);
            continue;
          }
        }
      }
    }
  }
コード例 #8
0
ファイル: ItemNeedle.java プロジェクト: Jamezo97/CloneCraft
  @Override
  public boolean hitEntity(
      ItemStack par1ItemStack, EntityLivingBase hit, EntityLivingBase playerParam) {
    if (playerParam instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) playerParam;
      if (par1ItemStack.getItemDamage() == 3) {
        if (hit instanceof EntityClone) {
          ((EntityClone) hit).injectStemcells(!player.isSneaking());
          player.worldObj.playSoundAtEntity(
              hit,
              "clonecraft:needle.inject",
              1.0F,
              1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);

          if (!hit.worldObj.isRemote) {
            if (par1ItemStack.stackSize == 1 && !player.capabilities.isCreativeMode) {
              new ItemData(par1ItemStack).empty().save(par1ItemStack);
              par1ItemStack.setItemDamage(0);
            } else if (par1ItemStack.stackSize > 1) {
              par1ItemStack.stackSize--;
              ItemStack newStack = par1ItemStack.copy();
              newStack.stackSize = 1;
              new ItemData(newStack).empty().save(newStack);
              newStack.setItemDamage(0);

              CloneCraftHelper.addToInventory(player.inventory, 0, 36, newStack);

              if (newStack.stackSize > 0) {
                CloneCraftHelper.dropAtEntity(player, newStack.copy());
              }
            }
          }

          return false;
        }
      } else {
        return tryFill(par1ItemStack, hit.worldObj, hit, player.inventory);
      }
    }
    return false;
  }
コード例 #9
0
  public void initGuiComponents() {
    int w = width;
    int h = height - topSectionHeight_b;
    CloneOptions op = clone.getOptions();
    int optionsAmount = op.size() + 1;

    int minButtonWidth = 100;
    int minButtonHeight = 20;

    int qAccross = 2;
    int qDown = (int) Math.ceil(optionsAmount / ((double) qAccross));

    int bWidth = (w - spacing) / qAccross - spacing;
    int bHeight = (h - spacing) / qDown - spacing;

    while (bHeight < 18) {
      qAccross++;
      qDown = (int) Math.ceil(optionsAmount / ((double) qAccross));

      bWidth = (w - spacing) / qAccross - spacing;
      bHeight = (h - spacing) / qDown - spacing;
      if (bWidth < minButtonWidth) {
        qAccross--;
        qDown = (int) Math.ceil(optionsAmount / ((double) qAccross));

        bWidth = (w - spacing) / qAccross - spacing;
        bHeight = (h - spacing) / qDown - spacing;
        break;
      }
    }

    float scaleW = (float) (bWidth) / ((float) minButtonWidth);
    float scaleH = (float) (bHeight) / ((float) minButtonHeight);
    float scale = scaleW < scaleH ? scaleW : scaleH;
    if (scale < 1) {
      scale = 1;
    } else {
      int scalePoints = 256;
      while (scalePoints >= 1) {
        if (scale > scalePoints) {
          scale = scalePoints;
          break;
        }
        scalePoints /= 2;
      }
    }
    int a = 0;
    for (; a < optionsAmount - 1; a++) {
      CloneOption option = op.getOptionByIndex(a);
      if (option != null) {
        buttonList.add(
            new ButtonCloneOption(
                -100,
                spacing + (spacing + bWidth) * (a / qDown),
                spacing + topSectionHeight_b + spacing + (spacing + bHeight) * (a % qDown),
                bWidth,
                bHeight,
                option,
                scale));
      }
    }

    buttonList.add(
        new GuiColourButton(
                0,
                spacing + (spacing + bWidth) * (a / qDown),
                spacing + topSectionHeight_b + spacing + (spacing + bHeight) * (a % qDown),
                bWidth,
                bHeight,
                "Done")
            .setColours(0xff888888, 0xff777777, 0xffcccccc)
            .setScale(scale));
  }
コード例 #10
0
 @Override
 public void write(DataOutputStream out, EntityClone clone) throws IOException {
   out.writeBoolean(clone.getBuildAI().isRunning());
   out.writeInt(clone.getBuildAI().getSchemFullSize());
   out.write(clone.getBuildAI().getBuildState());
 }