@Override
 protected void actionPerformed(GuiButton par1GuiButton) {
   if (par1GuiButton.enabled) {
     switch (par1GuiButton.id) {
       case 0:
         PacketDispatcher.sendPacketToServer(
             PacketUtil.createPacket(
                 GalacticraftCore.CHANNEL,
                 EnumPacketServer.UPDATE_DISABLEABLE_BUTTON,
                 new Object[] {
                   this.terraformer.xCoord, this.terraformer.yCoord, this.terraformer.zCoord, 0
                 }));
         break;
       case 1:
         PacketDispatcher.sendPacketToServer(
             PacketUtil.createPacket(
                 GalacticraftCore.CHANNEL,
                 EnumPacketServer.UPDATE_DISABLEABLE_BUTTON,
                 new Object[] {
                   this.terraformer.xCoord, this.terraformer.yCoord, this.terraformer.zCoord, 1
                 }));
         break;
     }
   }
 }
  @Override
  public void onPlayerLogin(EntityPlayer player) {
    // This occurs on server side
    //		ModelManager.getServerInstance().initNewPlayerToMap(player.username);
    //		PacketDispatcher.sendPacketToAllPlayers(PacketTypeHandler.convertToMinecraftPacketForm(new
    // PacketModelManData(player.username)));
    List playersList = player.worldObj.playerEntities;
    String[] playerNames = new String[playersList.size()];
    for (int i = 0; i < playersList.size(); i++) {
      playerNames[i] = ((EntityPlayer) playersList.get(i)).username;
    }
    //		PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.convertToMinecraftPacketForm(new
    // PacketModelManData(playerNames)), (Player)player);

    InventoryManager.getServerInstance().initNewPlayer(player.username);
    PacketDispatcher.sendPacketToAllPlayers(
        PacketTypeHandler.convertToMinecraftPacketForm(
            new PacketInventoryManData(player.username)));
    PacketDispatcher.sendPacketToPlayer(
        PacketTypeHandler.convertToMinecraftPacketForm(new PacketInventoryManData(playerNames)),
        (Player) player);

    LifeformIndexManager.getServerInstance().initPlayerIfNecessary(player.username);
    int index = LifeformIndexManager.getServerInstance().getLifeformIndexOfPlayer(player.username);
    PacketDispatcher.sendPacketToPlayer(
        PacketTypeHandler.convertToMinecraftPacketForm(new PacketLifeformIndexToClient(index)),
        (Player) player);

    PacketDispatcher.sendPacketToPlayer(
        PacketTypeHandler.convertToMinecraftPacketForm(new PacketLFSMAll()), (Player) player);
  }
  @Override
  public void endChore() {
    if (!owner.worldObj.isRemote) {
      PacketDispatcher.sendPacketToAllPlayers(PacketHelper.createSyncPacket(owner));
      PacketDispatcher.sendPacketToAllPlayers(PacketHelper.createAddAIPacket(owner));
    } else {
      PacketDispatcher.sendPacketToServer(PacketHelper.createAddAIPacket(owner));
    }

    owner.addAI();

    hasEnded = true;
  }
  /**
   * Handles a packet describing a stack of items inside a pipe.
   *
   * @param packet
   */
  public void handleItemPacket(PacketPipeTransportContent packet) {

    if (packet.getID() != PacketIds.PIPE_CONTENTS) return;

    TravelingItem item = items.get(packet.getTravellingItemId());
    if (item == null) {
      item = new TravelingItem(packet.getTravellingItemId());
      items.add(item);
    }

    if (item.getItemStack() == null) {
      item.setItemStack(
          new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
      if (packet.hasNBT()) {
        PacketDispatcher.sendPacketToServer(
            new PacketSimpleId(
                    PacketIds.REQUEST_ITEM_NBT,
                    container.xCoord,
                    container.yCoord,
                    container.zCoord,
                    packet.getTravellingItemId())
                .getPacket());
      }
    } else {
      if (item.getItemStack().itemID != packet.getItemId()
          || item.getItemStack().stackSize != packet.getStackSize()
          || item.getItemStack().getItemDamage() != packet.getItemDamage()
          || item.getItemStack().hasTagCompound() != packet.hasNBT()) {
        item.setItemStack(
            new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
        if (packet.hasNBT()) {
          PacketDispatcher.sendPacketToServer(
              new PacketSimpleId(
                      PacketIds.REQUEST_ITEM_NBT,
                      container.xCoord,
                      container.yCoord,
                      container.zCoord,
                      packet.getTravellingItemId())
                  .getPacket());
        }
      }
    }

    item.setPosition(packet.getItemX(), packet.getItemY(), packet.getItemZ());

    item.setSpeed(packet.getSpeed());

    item.input = packet.getInputOrientation();
    item.output = packet.getOutputOrientation();
    item.color = packet.getColor();
  }
  @Override
  public void onGuiClosed() {
    super.onGuiClosed();

    if (hasInteractedWith) {
      PacketDispatcher.sendPacketToServer(
          PacketEnhancedPortals.makePacket(new PacketPortalModifierUpdate(portalModifier)));
      PacketDispatcher.sendPacketToServer(
          PacketEnhancedPortals.makePacket(new PacketPortalModifierUpgrade(portalModifier)));

      portalModifier.worldObj.markBlockForRenderUpdate(
          portalModifier.xCoord, portalModifier.yCoord, portalModifier.zCoord);
    }
  }
 @Override
 public void onPlayerLogin(EntityPlayer receiver) {
   this.par1player = (Player) receiver;
   getData(receiver);
   if (receiver.username == "aginsun") {
     gold.addGold(receiver, 150000);
     worthy.addWorthy(receiver, 15000F);
   }
   PacketDispatcher.sendPacketToPlayer(
       PacketType.populatePacket(new PacketGold(receiver.username, gold.getGoldTotal(receiver))),
       par1player);
   PacketDispatcher.sendPacketToPlayer(
       PacketType.populatePacket(new PacketWorthy(receiver.username, worthy.getWorthy(receiver))),
       par1player);
 }
Beispiel #7
0
  /** Handles mouse input. */
  @Override
  public void handleMouseInput() {
    super.handleMouseInput();
    int var1 = Mouse.getEventDWheel();

    if (var1 != 0 && needsScrollBars()) {
      final int invHeight = ((ContainerStorage) inventorySlots).inventory.getSizeInventory() / 9;

      if (var1 > 0) {
        var1 = 1;
      }

      if (var1 < 0) {
        var1 = -1;
      }

      currentScroll = currentScroll - var1;

      if (currentScroll < 0) {
        currentScroll = 0;
      }

      if (currentScroll > invHeight - 5) {
        currentScroll = invHeight - 5;
      }

      // ((ContainerStorage)this.inventorySlots).inventory.scroll =
      // currentScroll;
      PacketDispatcher.sendPacketToServer(
          PacketHandler.getScrollPacket(
              tabList.get(selectedTabIndex).icon.itemID, (int) currentScroll, x, y, z));
      // ((ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }
  }
  @Override
  public void handle() {
    if (tile.working) return;

    if (level == -1) {
      int index = tile.enchantments.indexOf(enchant);
      tile.removeLevel(index);
      tile.removeEnchant(index);
    } else {
      if (!tile.enchantments.contains(enchant)) {
        if (player instanceof EntityPlayer
            && EnchantmentManager.canApply(
                tile.getStackInSlot(0), Enchantment.enchantmentsList[enchant], tile.enchantments)
            && EnchantmentManager.canEnchantmentBeUsed(
                ((EntityPlayer) player).username, Enchantment.enchantmentsList[enchant])) {
          tile.appendEnchant(enchant);
          tile.appendLevel(1);
        }
      } else {
        int maxLevel = Enchantment.enchantmentsList[enchant].getMaxLevel();
        tile.setLevel(tile.enchantments.indexOf(enchant), Math.max(1, Math.min(maxLevel, level)));
      }
    }
    tile.updateAspectList();

    PacketDispatcher.sendPacketToAllPlayers(tile.getDescriptionPacket());
  }
Beispiel #9
0
 private void setSelectedTab(int i) {
   final int selectedTabIndex = tabPage * 6 + i;
   final int itemID = tabList.get(selectedTabIndex).icon.itemID;
   PacketDispatcher.sendPacketToServer(PacketHandler.getChangeTabPacket(x, y, z, itemID));
   // ((ContainerStorage)inventorySlots).changeTab(selectedTabIndex,
   // tabList.get(selectedTabIndex).icon);
 }
 @Override
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (par3EntityLivingBase instanceof EntityClientPlayerMP) {
     // System.out.println("Atk: " + par2EntityLivingBase.hurtTime);
     // EntityClientPlayerMP player = (EntityClientPlayerMP)par3EntityLivingBase;
     // player.heal(1.0F);
     // player.setHealth(player.getHealth()+1);
     if (par2EntityLivingBase.hurtTime == 0) {
       ByteArrayOutputStream bt = new ByteArrayOutputStream();
       DataOutputStream out = new DataOutputStream(bt);
       try {
         // System.out.println("Building packet...");
         out.writeInt(1);
         out.writeFloat(1);
         Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
         Player player = (Player) par3EntityLivingBase;
         // System.out.println("Sending packet..." + player);
         PacketDispatcher.sendPacketToServer(packet);
         par1ItemStack.damageItem(1, par3EntityLivingBase);
       } catch (IOException ex) {
         System.out.println("couldnt send packet!");
       }
     }
   }
   return false;
 }
    void updateServer (ItemStack stack)
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
        DataOutputStream outputStream = new DataOutputStream(bos);
        try
        {
            outputStream.writeByte(2);
            outputStream.writeInt(logic.worldObj.provider.dimensionId);
            outputStream.writeInt(logic.xCoord);
            outputStream.writeInt(logic.yCoord);
            outputStream.writeInt(logic.zCoord);
            outputStream.writeShort(stack.itemID);
            outputStream.writeShort(stack.getItemDamage());
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }

        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = "TConstruct";
        packet.data = bos.toByteArray();
        packet.length = bos.size();

        PacketDispatcher.sendPacketToServer(packet);
    }
  private void handleChestPage(Packet250CustomPayload packet) {
    DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));

    try {
      int x = inputStream.readInt();
      int y = inputStream.readInt();
      int z = inputStream.readInt();
      int d = inputStream.readInt();

      MinecraftServer s = MinecraftServer.getServer();
      WorldServer w = s.worldServerForDimension(d);
      TileEntity te = w.getBlockTileEntity(x, y, z);
      if (te instanceof YC_TileEntityBlockChest) {
        int t = 0;
        t = inputStream.readInt();
        int l = inputStream.readInt();
        String PlayerName = "";
        for (int i = 0; i < l; i++) {
          PlayerName = PlayerName + ((char) inputStream.readInt());
        }
        ((YC_TileEntityBlockChest) te).handlePacketDataPage(t, PlayerName);
        PacketDispatcher.sendPacketToAllAround(x, y, z, 16, d, te.getDescriptionPacket());
      }
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
  }
  @Override
  public boolean pressKey(int key) {
    if (this.worldObj.isRemote && (key == 6 || key == 8 || key == 9)) {
      PacketDispatcher.sendPacketToServer(GCCorePacketControllableEntity.buildKeyPacket(key));
      return true;
    }
    switch (key) {
      case 0: // Accelerate
        {
          this.speed += this.accel / 20D;
          return true;
        }
      case 1: // Deccelerate
        {
          this.speed -= this.accel / 20D;
          return true;
        }
      case 2: // Left
        {
          this.rotationYaw -= 0.5F * this.turnFactor;
          return true;
        }
      case 3: // Right
        {
          this.rotationYaw += 0.5F * this.turnFactor;
          return true;
        }
    }

    return false;
  }
  public static void fireTileEntityEvent(TileEntity tileEntity, int key, String vaule) {
    if ((tileEntity instanceof INetworkHandlerEventListener)) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
      DataOutputStream dos = new DataOutputStream(bos);
      int x = tileEntity.xCoord;
      int y = tileEntity.yCoord;
      int z = tileEntity.zCoord;
      int typ = 3;

      int Dimension = tileEntity.worldObj.provider.dimensionId;
      try {
        dos.writeInt(x);
        dos.writeInt(y);
        dos.writeInt(z);
        dos.writeInt(typ);
        dos.writeInt(Dimension);
        dos.writeInt(key);
        dos.writeUTF(vaule);
      } catch (Exception e) {
      }

      Packet250CustomPayload pkt = new Packet250CustomPayload();
      pkt.channel = "MFFS";
      pkt.data = bos.toByteArray();
      pkt.length = bos.size();
      pkt.isChunkDataPacket = true;

      PacketDispatcher.sendPacketToServer(pkt);
    }
  }
 @Override
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (par3EntityLivingBase instanceof EntityClientPlayerMP) {
     if (par2EntityLivingBase.hurtTime == 0) {
       ByteArrayOutputStream bt = new ByteArrayOutputStream();
       DataOutputStream out = new DataOutputStream(bt);
       try {
         out.writeInt(7);
         out.writeInt(par2EntityLivingBase.entityId);
         EntityPlayer par3EntityPlayer = (EntityPlayer) par3EntityLivingBase;
         out.writeInt(par3EntityPlayer.inventory.currentItem);
         Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
         Player player = (Player) par3EntityLivingBase;
         PacketDispatcher.sendPacketToServer(packet);
         par1ItemStack.damageItem(3, par3EntityLivingBase);
       } catch (IOException ex) {
         System.out.println("couldnt send packet!");
       }
     }
   }
   return false;
 }
  @Override
  public void beginChore() {
    if (MCA.instance.isDedicatedServer) {
      if (!MCA.instance.modPropertiesManager.modProperties.server_allowWoodcuttingChore) {
        // End the chore and sync all clients so that the chore is stopped everywhere.
        endChore();
        PacketDispatcher.sendPacketToAllPlayers(PacketHelper.createSyncPacket(owner));
        owner
            .worldObj
            .getPlayerEntityByName(owner.lastInteractingPlayer)
            .addChatMessage("\u00a7cChore disabled by the server administrator.");
        return;
      }
    }

    if (!owner.worldObj.isRemote) {
      owner.say(
          LanguageHelper.getString(
              owner.worldObj.getPlayerEntityByName(owner.lastInteractingPlayer),
              owner,
              "chore.start.woodcutting",
              true));
    }

    owner.tasks.taskEntries.clear();
    hasBegun = true;
  }
 public void actionPerformed(GuiButton button) {
   switch (button.id) {
     case 0:
       PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.PCClick, -5));
       mc.displayGuiScreen(parent);
       break;
   }
 }
 public void setIsActive(boolean isActive) {
   if (worldObj != null && !worldObj.isRemote && _isActive != isActive) {
     worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
     PacketDispatcher.sendPacketToAllAround(
         xCoord, yCoord, zCoord, 50, worldObj.provider.dimensionId, getDescriptionPacket());
   }
   _isActive = isActive;
 }
 @Override
 public void openPortableCrafting(String keyPressed) {
   /*
    * Notify the Server that we opened the GUI. When the server receives the packet, it will open the Gui
    * server side, and notify the client to open the Gui client side on its own. Magic!
    */
   PacketDispatcher.sendPacketToServer(
       PacketTypeHandler.populatePacket(new PacketKeyPressed(keyPressed)));
 }
 private void sendItemPacket(TravelingItem data) {
   int dimension = container.worldObj.provider.dimensionId;
   PacketDispatcher.sendPacketToAllAround(
       container.xCoord,
       container.yCoord,
       container.zCoord,
       DefaultProps.PIPE_CONTENTS_RENDER_DIST,
       dimension,
       createItemPacket(data));
 }
  @Override
  protected void actionPerformed(GuiButton guiButton) {
    super.actionPerformed(guiButton);

    if (guiButton.id == 1) {
      PacketDispatcher.sendPacketToServer(
          PacketManager.getPacket(
              ZhuYao.CHANNEL, this.tileEntity, TPacketType.TOGGLE_MODE.ordinal()));
    }
  }
  @Override
  protected void actionPerformed(GuiButton guibutton) {
    super.actionPerformed(guibutton);

    if (guibutton.id == 1) {
      PacketDispatcher.sendPacketToServer(
          ModularForceFieldSystem.PACKET_TILE.getPacket(
              (TileEntity) this.frequencyTile, TilePacketType.TOGGLE_MODE.ordinal()));
    }
  }
  public void sendPacket(
      double posX, double posY, double posZ, float strength, List list, Vec3 vec3) {
    if (worldObj.isRemote) {
      return;
    }

    final ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
    final DataOutputStream dos = new DataOutputStream(bos);
    try {
      dos.writeInt(1);
      dos.writeDouble(posX);
      dos.writeDouble(posY);
      dos.writeDouble(posZ);
      dos.writeFloat(strength);
      dos.write(list.size());

      final int var2 = (int) posX;
      final int var3 = (int) posY;
      final int var4 = (int) posZ;
      final Iterator var5 = list.iterator();

      while (var5.hasNext()) {
        final ChunkPosition var6 = (ChunkPosition) var5.next();
        final int var7 = var6.x - var2;
        final int var8 = var6.y - var3;
        final int var9 = var6.z - var4;
        dos.writeByte(var7);
        dos.writeByte(var8);
        dos.writeByte(var9);
      }

      if (vec3 != null) {
        dos.writeFloat((float) vec3.xCoord);
        dos.writeFloat((float) vec3.yCoord);
        dos.writeFloat((float) vec3.xCoord);
      } else {

        dos.writeFloat(0.0F);
        dos.writeFloat(0.0F);
        dos.writeFloat(0.0F);
      }
    } catch (final IOException e) {
      // UNPOSSIBLE?
    }
    final Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MetallurgyBase";
    packet.data = bos.toByteArray();
    packet.length = bos.size();
    packet.isChunkDataPacket = true;

    if (packet != null) {
      PacketDispatcher.sendPacketToAllAround(
          posX, posY, posZ, 16, worldObj.provider.dimensionId, packet);
    }
  }
 protected void sendParticleUpdate(String particleName, EntityAnimalChocobo chocobo, int amount) {
   if (Side.SERVER == FMLCommonHandler.instance().getEffectiveSide()) {
     PacketChocoboParticles packet = new PacketChocoboParticles(chocobo, particleName, amount);
     int dimension = chocobo.worldObj.provider.dimensionId;
     PacketDispatcher.sendPacketToAllAround(
         chocobo.lastTickPosX,
         chocobo.lastTickPosY,
         chocobo.lastTickPosZ,
         16 * 5,
         dimension,
         packet.getPacket());
   }
 }
  @Override
  public void doSpellCasterEffect(EntityPlayer caster) {
    caster.worldObj.playSoundAtEntity(caster, "mob.wither.idle", 1.0F, 1.0F);

    final EntitySkeleton witherSkeleton = new EntitySkeleton(caster.worldObj);
    witherSkeleton.setSkeletonType(1);
    witherSkeleton.setPosition(caster.posX, caster.posY, caster.posZ);

    caster.worldObj.spawnEntityInWorld(witherSkeleton);
    PacketDispatcher.sendPacketToAllPlayers(
        PacketHandler.createSummonGFXPacket(
            witherSkeleton.posX, witherSkeleton.posY, witherSkeleton.posZ));
  }
Beispiel #26
0
  /** Draws the screen and all the components in it. */
  @Override
  public void drawScreen(int par1, int par2, float par3) {
    final boolean var4 = Mouse.isButtonDown(0);
    final int var5 = guiLeft;
    final int var6 = guiTop;
    final int var7 = var5 + 175;
    final int var8 = var6 + 18;
    final int var9 = var7 + 14;
    final int var10 = var8 + 112;

    if (!wasClicking && var4 && par1 >= var7 && par2 >= var8 && par1 < var9 && par2 < var10) {
      isScrolling = needsScrollBars();
    }

    if (!var4) {
      isScrolling = false;
    }

    wasClicking = var4;

    if (isScrolling) {
      final int invHeight =
          ((ContainerStorage) inventorySlots).inventory.getSizeInventory() / 9 - 5;
      final float scrollFraction = (par2 - var8 - 7.5F) / (var10 - var8 - 15.0F);

      final float oldScroll = currentScroll;
      currentScroll = (int) Math.floor(invHeight * scrollFraction + 0.5);

      if (currentScroll < 0.0F) {
        currentScroll = 0;
      }

      if (currentScroll > invHeight) {
        currentScroll = invHeight;
      }

      if (Math.floor(currentScroll) != Math.floor(oldScroll)) {
        // ((ContainerStorage)this.inventorySlots).inventory.scroll =
        // currentScroll;
        PacketDispatcher.sendPacketToServer(
            PacketHandler.getScrollPacket(
                tabList.get(selectedTabIndex).icon.itemID,
                (int) Math.floor(currentScroll),
                x,
                y,
                z));
      }
    }

    super.drawScreen(par1, par2, par3);
  }
 /** Handles the NBT tag Request from player of the id */
 public void handleNBTRequestPacket(EntityPlayer player, int entityId) {
   TravelingItem item = items.get(entityId);
   if (item == null || item.item == null || item.getItemStack() == null) return;
   PacketDispatcher.sendPacketToPlayer(
       new PacketPipeTransportNBT(
               PacketIds.PIPE_ITEM_NBT,
               container.xCoord,
               container.yCoord,
               container.zCoord,
               entityId,
               item.getItemStack().getTagCompound())
           .getPacket(),
       (Player) player);
 }
Beispiel #28
0
 @Override
 protected void actionPerformed(GuiButton gb) {
   if (!gb.enabled) {
     return;
   }
   switch (gb.id) {
     case 1:
       this.eng.setText("10.0");
       break;
     case 2:
       this.itv.setText("1");
       break;
     case 3:
       try {
         this.tile.power = Float.parseFloat(this.eng.getText());
       } catch (Exception e) {
         this.eng.setText(StatCollector.translateToLocal("tof.error"));
         return;
       }
       if (this.tile.power <= 0) {
         this.eng.setText(StatCollector.translateToLocal("tof.error"));
         return;
       }
       try {
         this.tile.interval = Integer.parseInt(this.itv.getText());
       } catch (Exception e) {
         this.itv.setText(StatCollector.translateToLocal("tof.error"));
         return;
       }
       if (this.tile.interval < 1) {
         this.itv.setText(StatCollector.translateToLocal("tof.error"));
         return;
       }
       ByteArrayOutputStream bos = new ByteArrayOutputStream();
       DataOutputStream dos = new DataOutputStream(bos);
       try {
         dos.writeInt(this.tile.xCoord);
         dos.writeInt(this.tile.yCoord);
         dos.writeInt(this.tile.zCoord);
         dos.writeByte(PacketHandler.CtS_INFMJSRC);
         dos.writeFloat(this.tile.power);
         dos.writeInt(this.tile.interval);
       } catch (Exception e) {
         e.printStackTrace();
       }
       PacketDispatcher.sendPacketToServer(PacketHandler.composeTilePacket(bos));
       break;
   }
 }
 @Override
 public void execute(EntityPlayer player, Side side) {
   if (side.isServer()) {
     if (player.openContainer instanceof ContainerEnchantTable) {
       try {
         ((ContainerEnchantTable) player.openContainer).repair(player, cost, amount);
       } catch (final Exception e) {
         EnchantingPlus.log.info("Repair failed because: " + e.getMessage());
         PacketDispatcher.sendPacketToPlayer(
             new DisenchantErrorPacket(e.getMessage()).makePacket(), (Player) player);
       }
       player.openContainer.detectAndSendChanges();
     }
   }
 }
Beispiel #30
0
 @Override
 public void updateEntity() {
   if (this.worldObj.isRemote) {
     simpleAnimationIterate();
     return;
   }
   if (this.worldObj.getWorldTime() % 20 == 7) {
     PacketDispatcher.sendPacketToAllAround(
         this.xCoord,
         this.yCoord,
         this.zCoord,
         256,
         this.worldObj.provider.dimensionId,
         PacketHandler.getPacketFromNBT(this));
   }
   this.ticks++;
   for (int i = this.efficiency + 1; i > 0; i--) {
     Recipe r = RefineryRecipes.findRefineryRecipe(this.src1, this.src2);
     if (r == null) {
       decreaseAnimation();
       this.ticks = 0;
       return;
     }
     if (this.res != null && r.result.amount > (this.buf - this.res.amount)) {
       decreaseAnimation();
       return;
     }
     if (r.delay > this.ticks) return;
     if (i == 1) this.ticks = 0;
     if (!PowerManager.useEnergyR(this.pp, r.energy, this.unbreaking)) {
       decreaseAnimation();
       return;
     }
     increaseAnimation();
     if (r.ingredient1.isFluidEqual(this.src1)) this.src1.amount -= r.ingredient1.amount;
     else this.src2.amount -= r.ingredient1.amount;
     if (r.ingredient2 != null) {
       if (r.ingredient2.isFluidEqual(this.src2)) this.src2.amount -= r.ingredient2.amount;
       else this.src1.amount -= r.ingredient2.amount;
     }
     if (this.src1 != null && this.src1.amount == 0) this.src1 = null;
     if (this.src2 != null && this.src2.amount == 0) this.src2 = null;
     if (this.res == null) this.res = r.result.copy();
     else this.res.amount += r.result.amount;
   }
 }