@Override public void detectAndSendChanges() { super.detectAndSendChanges(); if(lastindex!=index){ pictureOutSlot.decrStackSize(64); lastindex=index; } if(totalPictureNum!=0&&!pictureOutSlot.getHasStack()&&index!=-1){ String imageName = listPid.get(index); ItemStack itemPicture = new ItemStack(ItemLoader.itemPicture); NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("pid", imageName); itemPicture.setTagCompound(nbt); pictureOutSlot.putStack(itemPicture); } // System.out.println(tileEntity.getBurnTime()); for (IContainerListener i : this.listeners) { i.sendProgressBarUpdate(this, 0, totalPictureNum); i.sendProgressBarUpdate(this, 1, index); } }
@Override public void addListener(IContainerListener listener) { if (listener instanceof EntityPlayerMP) { EntityPlayerMP l = (EntityPlayerMP) listener; if (!playerList.contains(l)) { playerList.add(l); //detectAndSendChanges(); } } if (listeners.contains(listener)) { throw new IllegalArgumentException("Listener already listening"); } else { listeners.add(listener); //listener.sendAllContents(this, getInventory()); detectAndSendChanges(); } //super.addListener(listener); }
public void detectAndSendChanges () { super.detectAndSendChanges(); for (IContainerListener listener : this.listeners) { if (cookTime != tile.getField(2)) listener.sendWindowProperty(this, 2, tile.getField(2)); if (furnaceBurnTime != tile.getField(0)) listener.sendWindowProperty(this, 0, tile.getField(0)); if (currentItemBurnTime != tile.getField(1)) listener.sendWindowProperty(this, 1, tile.getField(1)); if (totalCookTime != tile.getField(3)) listener.sendWindowProperty(this, 3, tile.getField(3)); } cookTime = tile.getField(2); furnaceBurnTime = tile.getField(0); currentItemBurnTime = tile.getField(1); totalCookTime = tile.getField(3); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener listener : listeners) { for (int id = 0; id < prevFieldValues.length; id++) { if (prevFieldValues[id] != fieldSupplier.getField(id)) { listener.sendWindowProperty(this, id, fieldSupplier.getField(id)); } } } for (int id = 0; id < prevFieldValues.length; id++) { prevFieldValues[id] = fieldSupplier.getField(id); } }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); if (this.colors == null) this.colors = new int[this.tileInventory.getFieldCount()]; boolean updateField[] = new boolean[this.tileInventory.getFieldCount()]; for (int i = 0; i < this.colors.length; i++) { if (this.colors[i] != this.tileInventory.getField(i)) { this.colors[i] = this.tileInventory.getField(i); updateField[i] = true; } } for (IContainerListener listener : this.listeners) for (int i = 0; i < this.tileInventory.getFieldCount(); i++) if (updateField[i]) listener.sendWindowProperty(this, i, colors[i]); }
/** * Looks for changes made in the container, sends them to every listener. */ @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = this.listeners.get(i); if (this.cookTime != this.tileFurnace.getField(2)) icontainerlistener.sendWindowProperty(this, 2, this.tileFurnace.getField(2)); if (this.furnaceBurnTime != this.tileFurnace.getField(0)) icontainerlistener.sendWindowProperty(this, 0, this.tileFurnace.getField(0)); if (this.currentItemBurnTime != this.tileFurnace.getField(1)) icontainerlistener.sendWindowProperty(this, 1, this.tileFurnace.getField(1)); if (this.totalCookTime != this.tileFurnace.getField(3)) icontainerlistener.sendWindowProperty(this, 3, this.tileFurnace.getField(3)); } this.cookTime = this.tileFurnace.getField(2); this.furnaceBurnTime = this.tileFurnace.getField(0); this.currentItemBurnTime = this.tileFurnace.getField(1); this.totalCookTime = this.tileFurnace.getField(3); }
public void detectAndSendChanges() { super.detectAndSendChanges(); for(IContainerListener listener : this.listeners) { ItemStack weapon = this.mercenary.loadout.getStackInSlot(0); int loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0; if(this.primaryAmmo != this.mercenary.getAmmo(0)) { this.primaryAmmo = this.mercenary.getAmmo(0); //System.out.println("ammo in:"); listener.sendWindowProperty(this, 0, this.primaryAmmo); } weapon = this.mercenary.loadout.getStackInSlot(0); loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0; if(this.secondaryAmmo != this.mercenary.getAmmo(1) + loaded) { this.secondaryAmmo = this.mercenary.getAmmo(1) + loaded; listener.sendWindowProperty(this, 1, this.secondaryAmmo); } } }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener listener : listeners) { if (lastCookTime != tileEntity.cookTime) { listener.sendWindowProperty(this, 0, tileEntity.cookTime); } if (lastBurnTime != tileEntity.burnTime) { listener.sendWindowProperty(this, 1, tileEntity.burnTime); } if (lastItemBurnTime != tileEntity.currentItemBurnLength) { listener.sendWindowProperty(this, 2, tileEntity.currentItemBurnLength); } } lastBurnTime = tileEntity.burnTime; lastCookTime = tileEntity.cookTime; lastItemBurnTime = tileEntity.currentItemBurnLength; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); Iterator<IContainerListener> it = this.listeners.iterator(); while(it.hasNext()) { IContainerListener craft = it.next(); if (this.workTime != tileCherryBox.workTime) { craft.sendProgressBarUpdate(this, 0, tileCherryBox.workTime); } if (this.totalWorkTime != tileCherryBox.totalWorkTime) { craft.sendProgressBarUpdate(this, 1, tileCherryBox.totalWorkTime); } } this.workTime = tileCherryBox.workTime; this.totalWorkTime = tileCherryBox.totalWorkTime; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = (IContainerListener)this.listeners.get(i); if (this.progress != this.incubator.getField(0)) { icontainerlistener.sendProgressBarUpdate(this, 0, this.incubator.getField(0)); } else if (this.powerRemaining != this.incubator.getField(1)) { icontainerlistener.sendProgressBarUpdate(this, 1, this.incubator.getField(1)); } } this.progress = this.incubator.getField(0); this.powerRemaining = this.incubator.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored()) msg.add(0, te.getClientEnergyStored()); // crafter.sendProgressBarUpdate(this, 0, // te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 1, te.getField(0)); if (lastMaxProgress != te.getField(1)) crafter.sendWindowProperty(this, 2, te.getField(1)); msg.send(); } lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); lastMaxProgress = te.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { // if(lastEnergy != // te.getClientEnergyStored())crafter.sendProgressBarUpdate(this, 0, // te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 0, te.getField(0)); // if(lastMaxProgress != // te.getField(1))crafter.sendProgressBarUpdate(this, 2, // te.getField(1)); } // lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); // lastMaxProgress = te.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); int heat = MathHelper.floor(te.getHeat()); int progress = MathHelper.floor(((double) te.getProgress()) / TileEntityRubberBoiler.MAX_PROGRESS * 100); for (IContainerListener crafter : listeners) { if (this.heat != heat) crafter.sendWindowProperty(this, 0, heat); if (this.lastProgress != progress) crafter.sendWindowProperty(this, 1, progress); if (this.maxHeat != te.maxHeat) crafter.sendWindowProperty(this, 2, te.maxHeat); } sync.detectAndSendChanges(listeners); this.heat = heat; this.lastProgress = progress; this.maxHeat = te.maxHeat; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); int progress = te.getField(1) > 0 ? MathHelper.floor((1 - (((float) te.getField(0)) / te.getField(1))) * MAX_PROGRESS) : 0; for (IContainerListener crafter : listeners) { if (progress != lastProgress) { crafter.sendWindowProperty(this, 0, progress); } if (te.getField(2) != lastSolderingAlloy) { crafter.sendWindowProperty(this, 1, te.getField(2)); } if (te.craftingError != craftingErrorLast) { crafter.sendWindowProperty(this, 2, te.craftingError); } } lastProgress = progress; lastSolderingAlloy = te.getField(2); craftingErrorLast = te.craftingError; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored()) msg.add(0, te.getClientEnergyStored()); // crafter.sendProgressBarUpdate(this, 0, // te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 1, te.getField(0)); if (lastMaxProgress != te.getField(1)) crafter.sendWindowProperty(this, 2, te.getField(1)); if (lastVulcanizing != te.getField(2)) crafter.sendWindowProperty(this, 3, te.getField(2)); msg.send(); } sync.detectAndSendChanges(listeners); lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); lastMaxProgress = te.getField(1); lastVulcanizing = te.getField(2); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored())// crafter.sendProgressBarUpdate(this, // 0, // te.getClientEnergyStored()); msg.add(0, te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 1, te.getField(0)); // if(lastMaxProgress != // te.getField(1))crafter.sendProgressBarUpdate(this, 2, // te.getField(1)); msg.send(); } lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); // lastMaxProgress = te.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); int progress = te.getField(0) > 0 ? MathHelper.floor((1 - (((float) te.getField(0)) / te.maxProgress)) * 100) : 0; for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored()) msg.add(0, te.getClientEnergyStored()); // crafter.sendProgressBarUpdate(this, 0, // te.getClientEnergyStored()); if (lastProgress != progress) crafter.sendWindowProperty(this, 1, progress); msg.send(); } lastEnergy = te.getClientEnergyStored(); lastProgress = progress; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored()) msg.add(0, te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 1, te.getField(0)); if (lastMaxProgress != te.getField(1)) crafter.sendWindowProperty(this, 2, te.getField(1)); msg.send(); } sync.detectAndSendChanges(listeners); lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); lastMaxProgress = te.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); FluidStack tank = te.getTank().getFluid(); if (tank != null) tank = tank.copy(); int progress = te.getField(1) > 0 ? MathHelper.floor(((double) te.getField(0)) / te.getField(1) * 100) : 0; for (IContainerListener crafter : listeners) { if (!TomsModUtils.areFluidStacksEqual(tank, this.tank)) MessageFluidStackSync.sendTo(crafter, 0, tank); if (this.progress != progress) crafter.sendWindowProperty(this, 0, progress); } this.progress = progress; this.tank = tank; }
public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = (IContainerListener)this.listeners.get(i); if (this.dualCookTime != this.alloyfurnace.getField(0)) { icontainerlistener.sendProgressBarUpdate(this, 0, this.alloyfurnace.getField(0)); } if (this.dualPower != this.alloyfurnace.getField(1)) { icontainerlistener.sendProgressBarUpdate(this, 1, this.alloyfurnace.getField(1)); } } this.dualCookTime = this.alloyfurnace.getField(0); this.dualPower = this.alloyfurnace.getField(1); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (te.getField(0) != linkedLast) { crafter.sendWindowProperty(this, 0, te.getField(0)); } if (te.getField(1) != rangeLast) { crafter.sendWindowProperty(this, 1, te.getField(1)); } if (te.getField(2) != powerLast) { // crafter.sendProgressBarUpdate(this, 2, te.getField(2)); msg.add(2, te.getField(2)); } if (te.rsMode.ordinal() != lastRS) { crafter.sendWindowProperty(this, 3, te.rsMode.ordinal()); } msg.send(); } lastRS = te.rsMode.ordinal(); powerLast = te.getField(2); rangeLast = te.getField(1); linkedLast = te.getField(0); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); int compiledEditingCard = te.getCompiledRightsFromEditingCard(); for (IContainerListener crafter : listeners) { if (te.getField(0) != powerLast) { crafter.sendWindowProperty(this, 0, te.getField(0)); } if (te.rsMode.ordinal() != lastRS) { crafter.sendWindowProperty(this, 2, te.rsMode.ordinal()); } if (compiledEditingCard != this.cardLast) { crafter.sendWindowProperty(this, 1, compiledEditingCard); } } powerLast = te.getField(2); this.cardLast = compiledEditingCard; lastRS = te.rsMode.ordinal(); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (IContainerListener crafter : listeners) { MessageProgress msg = new MessageProgress(crafter); if (lastEnergy != te.getClientEnergyStored()) msg.add(0, te.getClientEnergyStored()); // crafter.sendProgressBarUpdate(this, 0, // te.getClientEnergyStored()); if (lastProgress != te.getField(0)) crafter.sendWindowProperty(this, 1, te.getField(0)); msg.send(); } lastEnergy = te.getClientEnergyStored(); lastProgress = te.getField(0); }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); int bucket = te.getProperties().useContainerItems ? 1 : 0, storedOnly = te.getProperties().storedOnly ? 1 : 0, time = te.getProperties().time; NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); boolean equals = tag.equals(tagLast); for (IContainerListener crafter : listeners) { if (bucket != lastBucket) crafter.sendWindowProperty(this, 0, bucket); if (storedOnly != lastStoredOnly) crafter.sendWindowProperty(this, 1, storedOnly); if (time != lastTime) crafter.sendWindowProperty(this, 2, time); if (!equals) sendTo(crafter, tag); } lastBucket = bucket; lastStoredOnly = storedOnly; lastTime = time; tagLast = tag; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); boolean sendData = false; if (this.isFirstLoad) { sendData = true; this.isFirstLoad = false; } sendData = sendData || lastMode != te.mode || lastItemMode != te.isItemMode || lastLock != te.isLocked || lastNBT != te.useNBT; if (sendData) for (IContainerListener crafter : listeners) { crafter.sendWindowProperty(this, 0, te.mode ? 1 : 0); crafter.sendWindowProperty(this, 1, te.isItemMode ? 1 : 0); crafter.sendWindowProperty(this, 2, te.isLocked ? 1 : 0); crafter.sendWindowProperty(this, 3, te.useNBT ? 1 : 0); } lastMode = te.mode; lastItemMode = te.isItemMode; lastLock = te.isLocked; lastNBT = te.useNBT; }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int j = 0; j < prevRemaining.length; j++) { if (prevRemaining[j] != tile.dryTimeRemaining[j]) { for (IContainerListener icrafting : this.listeners) { icrafting.sendWindowProperty(this, j, tile.dryTimeRemaining[j]); } prevRemaining[j] = tile.dryTimeRemaining[j]; } } }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); i++) { IContainerListener IContainerListener = this.listeners.get(i); if (this.power != tile.getPowerScaled(47)) { IContainerListener.sendProgressBarUpdate(this, 0, (int) tile.getPowerScaled(47)); } if (this.progress != tile.getProgress()) { IContainerListener.sendProgressBarUpdate(this, 1, tile.getProgress()); } if (this.burnTime != tile.getScaledBurnTime(13)) { IContainerListener.sendProgressBarUpdate(this, 2, tile.getScaledBurnTime(13)); } } }
@Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); i++) { IContainerListener IContainerListener = this.listeners.get(i); if (this.burnTime != tile.getField(1)) { IContainerListener.sendProgressBarUpdate(this, 0, tile.burnTime); } if (this.totalBurnTime != tile.getField(0)) { IContainerListener.sendProgressBarUpdate(this, 1, tile.totalBurnTime); } } this.burnTime = tile.getField(1); this.totalBurnTime = tile.getField(0); }