net.minecraft.inventory.IContainerListener Java Examples

The following examples show how to use net.minecraft.inventory.IContainerListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContainerGui.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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);
    }
}
 
Example #2
Source File: ContainerEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addListener(IContainerListener listener)
{
    super.addListener(listener);

    int b = 0;

    if (this.teef.burnTimeFresh != 0)
    {
        b = 100 * this.teef.burnTimeRemaining / this.teef.burnTimeFresh;
    }

    int c = 100 * this.teef.cookTime / TileEntityEnderFurnace.COOKTIME_DEFAULT;

    listener.sendWindowProperty(this, 0, c << 8 | b);
    listener.sendWindowProperty(this, 1, this.teef.outputToEnderChest ? 1 : 0);
}
 
Example #3
Source File: ContainerCampfirePot.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (int i = 0; i < this.listeners.size(); ++i) {
        IContainerListener icontainerlistener = this.listeners.get(i);

        if (this.burnTime != this.tileCampfire.getField(0)) {
            icontainerlistener.sendWindowProperty(this, 0, this.tileCampfire.getField(0));
        }

        if (this.processTime != this.tileCampfire.getField(1)) {
            icontainerlistener.sendWindowProperty(this, 1, this.tileCampfire.getField(1));
        }

        if (this.maxProcessTime != this.tileCampfire.getField(2)) {
            icontainerlistener.sendWindowProperty(this, 2, this.tileCampfire.getField(2));
        }
    }

    this.burnTime = this.tileCampfire.getField(0);
    this.processTime = this.tileCampfire.getField(1);
    this.maxProcessTime = this.tileCampfire.getField(2);
}
 
Example #4
Source File: ContainerAnvil.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void detectAndSendChanges()
{
	super.detectAndSendChanges();
	for (int i = 0; i < this.listeners.size(); ++i)
	{
		IContainerListener icrafting = (IContainerListener)this.listeners.get(i);

		if(this.recipeIndex != anvil.getField(0))
		{
			icrafting.sendProgressBarUpdate(this, 0, anvil.getField(0));
		}
	}

	this.recipeIndex = anvil.getField(0);
}
 
Example #5
Source File: ContainerMapleCauldron.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    for (int i = 0; i < this.listeners.size(); ++i) {
        IContainerListener icontainerlistener = this.listeners.get(i);

        if (this.mapleTime != this.tileCampfire.getField(0)) {
            icontainerlistener.sendWindowProperty(this, 0, this.tileCampfire.getField(0));
        }

        if (this.cookTime != this.tileCampfire.getField(1)) {
            icontainerlistener.sendWindowProperty(this, 1, this.tileCampfire.getField(1));
        }

    }
    this.mapleTime = this.tileCampfire.getField(0);
    this.cookTime = this.tileCampfire.getField(1);
}
 
Example #6
Source File: ContainerLargeStacks.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addListener(IContainerListener listener)
{
    if (this.listeners.contains(listener))
    {
        throw new IllegalArgumentException("Listener already listening");
    }
    else
    {
        this.listeners.add(listener);

        if (listener instanceof EntityPlayerMP)
        {
            EntityPlayerMP player = (EntityPlayerMP) listener;
            player.connection.sendPacket(new SPacketSetSlot(-1, -1, player.inventory.getItemStack()));
            this.syncAllSlots(player);
        }

        this.detectAndSendChanges();
    }
}
 
Example #7
Source File: ContainerMemoryChest.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void detectAndSendChanges()
{
    boolean isPublic = this.temc.isPublic();

    for (int j = 0; j < this.listeners.size(); ++j)
    {
        IContainerListener listener = this.listeners.get(j);

        if (this.isPublic != isPublic)
        {
            listener.sendWindowProperty(this, 0, isPublic ? 1 : 0);
        }
    }

    this.isPublic = isPublic;

    this.syncLockableSlots(this.temc.getInventory(), 0, 1, this.lockedLast, this.templateStacksLast);

    super.detectAndSendChanges();
}
 
Example #8
Source File: ContainerHeatDryer.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener listener : this.listeners) {
        if (this.lastProgress != this.tile.progress) {
            listener.sendProgressBarUpdate(this, 1, this.tile.progress);
        }
        if (this.lastEnergy != this.tile.energy) {
            listener.sendProgressBarUpdate(this, 2, (int) this.tile.energy);
        }
    }

    this.lastEnergy = this.tile.energy;
    this.lastProgress = this.tile.progress;
}
 
Example #9
Source File: ContainerStoneMortar.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (int i = 0; i < this.listeners.size(); ++i) {
        IContainerListener icontainerlistener = this.listeners.get(i);

        if (this.processTime != this.tileCampfire.getField(0)) {
            icontainerlistener.sendWindowProperty(this, 0, this.tileCampfire.getField(0));
        }

        if (this.maxProcessTime != this.tileCampfire.getField(1)) {
            icontainerlistener.sendWindowProperty(this, 1, this.tileCampfire.getField(1));
        }
    }

    this.processTime = this.tileCampfire.getField(0);
    this.maxProcessTime = this.tileCampfire.getField(1);
}
 
Example #10
Source File: OptimiserContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.OPTIMISERENERGY, this.packetEnergy);
		checkField(listener, EnumTileField.OPTIMISERFLUID, this.packetFluid);
		checkField(listener, EnumTileField.OPTIMISERGAS, this.packetGas);
		checkField(listener, EnumTileField.OPTIMISERPROGRESS, this.packetProgress);
		checkField(listener, EnumTileField.OPTIMISERCORES, this.cores);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.cores = this.tileEntity.getField(EnumTileField.OPTIMISERCORES);

	this.packetEnergy = this.tileEntity.getField(EnumTileField.OPTIMISERENERGY);
	this.packetFluid = this.tileEntity.getField(EnumTileField.OPTIMISERFLUID);
	this.packetGas = this.tileEntity.getField(EnumTileField.OPTIMISERGAS);
	this.packetProgress = this.tileEntity.getField(EnumTileField.OPTIMISERPROGRESS);
}
 
Example #11
Source File: ScrubberContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.GAS, this.gas);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.gas = this.tileEntity.getField(EnumTileField.GAS);
}
 
Example #12
Source File: FabricatorContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.FABRICATORSELECTION, this.selection);
		checkField(listener, EnumTileField.FABRICATORISPRINTING, this.printing);
		checkField(listener, EnumTileField.FABRICATORSTATUS, this.status);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.selection = this.tileEntity.getField(EnumTileField.FABRICATORSELECTION);
	this.printing = this.tileEntity.getField(EnumTileField.FABRICATORISPRINTING);
	this.status = this.tileEntity.getField(EnumTileField.FABRICATORSTATUS);
}
 
Example #13
Source File: ContainerCarbonizeFurnace.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener listener : this.listeners) {
        if (this.lastProgress != this.tile.progress) {
            listener.sendProgressBarUpdate(this, 0, this.tile.progress);
        }

        if (this.lastRequireEnergy != this.tile.requireEnergy) {
            listener.sendProgressBarUpdate(this, 1, (int) this.tile.requireEnergy);
        }

        if (this.lastEnergy != this.tile.energy) {
            listener.sendProgressBarUpdate(this, 2, (int) this.tile.energy);
        }
    }

    this.lastProgress = this.tile.progress;
    this.lastRequireEnergy = (int) this.tile.requireEnergy;
    this.lastEnergy = this.tile.energy;
}
 
Example #14
Source File: ContainerFluidKineticGenerator.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener listener : this.listeners) {
        if (this.fluidAmount != this.tile.fluidTank.getFluidAmount()) {
            listener.sendProgressBarUpdate(this, 0, this.tile.fluidTank.getFluidAmount());
        }
        if (this.tile.fluidTank.getFluid() != null && this.fluid != this.tile.fluidTank.getFluid().getFluid()) {
            listener.sendProgressBarUpdate(this, 1, FluidRegistry.getFluidID(this.tile.fluidTank.getFluid().getFluid()));
        }
    }

    this.fluidAmount = this.tile.fluidTank.getFluidAmount();
    if (this.tile.fluidTank.getFluid() != null) {
        this.fluid = this.tile.fluidTank.getFluid().getFluid();
    }
}
 
Example #15
Source File: ContainerPackager.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener listener : this.listeners) {
        if (this.lastProgress != this.tile.progress) {
            listener.sendProgressBarUpdate(this, 1, this.tile.progress);
        }
        if (this.lastEnergy != this.tile.energy) {
            listener.sendProgressBarUpdate(this, 2, (int) this.tile.energy);
        }
    }

    this.lastEnergy = this.tile.energy;
    this.lastProgress = this.tile.progress;
}
 
Example #16
Source File: BatteryContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.BATTERYINPUT, this.totalInput);
		checkField(listener, EnumTileField.BATTERYOUTPUT, this.totalOutput);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.totalInput = this.tileEntity.getField(EnumTileField.BATTERYINPUT);
	this.totalOutput = this.tileEntity.getField(EnumTileField.BATTERYOUTPUT);
}
 
Example #17
Source File: ContainerCreationStation.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addListener(IContainerListener listener)
{
    super.addListener(listener);

    int modeMask = this.tecs.getModeMask();
    int selection = this.tecs.getQuickMode() << 2 | this.tecs.getSelectedModuleSlot();
    int smeltProgress = this.tecs.getSmeltProgressScaled(1, 100) << 8 | this.tecs.getSmeltProgressScaled(0, 100);
    int fuelProgress = this.tecs.getBurnTimeRemainingScaled(1, 100) << 8 | this.tecs.getBurnTimeRemainingScaled(0, 100);

    listener.sendWindowProperty(this, 0, modeMask);
    listener.sendWindowProperty(this, 1, selection);
    listener.sendWindowProperty(this, 2, fuelProgress);
    listener.sendWindowProperty(this, 3, smeltProgress);
    listener.sendWindowProperty(this, 4, this.tecs.lastInteractedCraftingGrid);

    this.detectAndSendChanges();
}
 
Example #18
Source File: ContainerEUStorage.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener listener : this.listeners) {
        if (this.lastEnergy != this.tile.energy) {
            listener.sendProgressBarUpdate(this, 0, (int) this.tile.energy);
        }
        if (this.lastMode != this.tile.redstoneMode.ordinal()) {
            listener.sendProgressBarUpdate(this, 1, this.tile.redstoneMode.ordinal());
        }
    }

    this.lastEnergy = this.tile.energy;
    this.lastMode = this.tile.redstoneMode.ordinal();
}
 
Example #19
Source File: AlgaeBioreactorContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.GAS, this.gas);
		checkField(listener, EnumTileField.LIGHTBOOST, this.boost);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.gas = this.tileEntity.getField(EnumTileField.GAS);
	this.boost = this.tileEntity.getField(EnumTileField.LIGHTBOOST);
}
 
Example #20
Source File: CookerContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.HEAT, this.heat);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.MAXPROGRESS, this.maxProgress);
	}

	this.heat = this.tileEntity.getField(EnumTileField.HEAT);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.maxProgress = this.tileEntity.getField(EnumTileField.MAXPROGRESS);
}
 
Example #21
Source File: InjectorContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.NUTRIENT, this.nutrient);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.nutrient = this.tileEntity.getField(EnumTileField.NUTRIENT);
}
 
Example #22
Source File: ProcessorContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.MAXPROGRESS, this.maxProgress);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.maxProgress = this.tileEntity.getField(EnumTileField.MAXPROGRESS);
}
 
Example #23
Source File: ContainerParallelSpaceSU.java    From Production-Line with MIT License 6 votes vote down vote up
/**
 * Looks for changes made in the container, sends them to every listener.
 */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for (IContainerListener object : this.listeners) {
        if (this.lastEnergy != this.tile.energy) {
            object.sendProgressBarUpdate(this, 0, (int) this.tile.energy);
        }
        if (this.lastMode != this.tile.redstoneMode.ordinal()) {
            object.sendProgressBarUpdate(this, 1, this.tile.redstoneMode.ordinal());
        }
    }

    this.lastEnergy = this.tile.energy;
    this.lastMode = this.tile.redstoneMode.ordinal();
}
 
Example #24
Source File: BioreactorContainer.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int i = 0; i < this.listeners.size(); ++i) {

		IContainerListener listener = (IContainerListener) this.listeners.get(i);

		checkField(listener, EnumTileField.ENERGY, this.energy);
		checkField(listener, EnumTileField.FLUID, this.water);
		checkField(listener, EnumTileField.PROGRESS, this.progress);
		checkField(listener, EnumTileField.MAXPROGRESS, this.maxProgress);
	}

	this.energy = this.tileEntity.getField(EnumTileField.ENERGY);
	this.water = this.tileEntity.getField(EnumTileField.FLUID);
	this.progress = this.tileEntity.getField(EnumTileField.PROGRESS);
	this.maxProgress = this.tileEntity.getField(EnumTileField.MAXPROGRESS);
}
 
Example #25
Source File: ContainerEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void detectAndSendChanges()
{
    if (this.isClient == false)
    {
        for (int slot = 0; slot < this.inventorySlots.size(); slot++)
        {
            ItemStack currentStack = this.inventorySlots.get(slot).getStack();
            ItemStack prevStack = this.inventoryItemStacks.get(slot);

            if (ItemStack.areItemStacksEqual(prevStack, currentStack) == false)
            {
                prevStack = currentStack.isEmpty() ? ItemStack.EMPTY : currentStack.copy();
                this.inventoryItemStacks.set(slot, prevStack);

                for (int i = 0; i < this.listeners.size(); i++)
                {
                    IContainerListener listener = this.listeners.get(i);

                    if (listener instanceof EntityPlayerMP)
                    {
                        PacketHandler.INSTANCE.sendTo(new MessageSyncSlot(this.windowId, slot, prevStack), (EntityPlayerMP) listener);
                    }
                }
            }
        }
    }
}
 
Example #26
Source File: ContainerHandyChest.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void addListener(IContainerListener listener)
{
    super.addListener(listener);

    listener.sendWindowProperty(this, 0, this.tehc.getSelectedModule());
    listener.sendWindowProperty(this, 1, this.tehc.getQuickMode());
    listener.sendWindowProperty(this, 2, this.tehc.getLockMask());
}
 
Example #27
Source File: ContainerBase.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
protected void sendToCrafters(IMessage message){

        for(IContainerListener crafter : listeners) {
            if(crafter instanceof EntityPlayerMP) {
                NetworkHandler.sendTo(message, (EntityPlayerMP)crafter);
            }
        }
    }
 
Example #28
Source File: ContainerEnderInfuser.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void detectAndSendChanges()
{
    super.detectAndSendChanges();

    if (this.teef.chargeableItemCurrentCharge != this.ciCurrent)
    {
        this.ciCurrent = this.teef.chargeableItemCurrentCharge;
        this.ciCapacity = this.teef.chargeableItemCapacity;
        this.ciStarting = this.teef.chargeableItemStartingCharge;
        this.updateChargingProgress();
    }

    for (int i = 0; i < this.listeners.size(); ++i)
    {
        IContainerListener listener = this.listeners.get(i);

        // The values need to fit into a short, where these get truncated to in non-local SMP

        if (this.teef.amountStored != this.amountStored)
        {
            listener.sendWindowProperty(this, 0, this.teef.amountStored);
        }

        if (this.teef.meltingProgress != this.meltingProgress)
        {
            listener.sendWindowProperty(this, 1, this.teef.meltingProgress);
        }

        if (this.ciCurrentLast != this.ciCurrent)
        {
            listener.sendWindowProperty(this, 2, this.chargeProgress);
        }
    }

    this.ciCurrentLast = this.ciCurrent;
    this.amountStored = this.teef.amountStored;
    this.meltingProgress = this.teef.meltingProgress;
}
 
Example #29
Source File: ContainerQuickStackerAdvanced.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void addListener(IContainerListener listener)
{
    super.addListener(listener);

    listener.sendWindowProperty(this, 0, this.teqsa.isAreaMode() ? 1 : 0);
    listener.sendWindowProperty(this, 1, this.teqsa.getAreaModeSettings());
    listener.sendWindowProperty(this, 2, this.teqsa.getEnabledTargetsMask());
    listener.sendWindowProperty(this, 3, this.teqsa.getSelectedTarget());

    long mask = this.teqsa.getEnabledSlotsMask();
    listener.sendWindowProperty(this, 4, (short)((mask >>> 32) & 0xFFFF));
    listener.sendWindowProperty(this, 5, (short)((mask >>> 16) & 0xFFFF));
    listener.sendWindowProperty(this, 6, (short)(mask & 0xFFFF));
}
 
Example #30
Source File: ContainerEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void detectAndSendChanges()
{
    super.detectAndSendChanges();

    IContainerListener listener;

    for (int i = 0; i < this.listeners.size(); i++)
    {
        listener = this.listeners.get(i);

        // Note: the value gets truncated to a short in non-local SMP
        if (this.teef.burnTimeRemaining != this.burnTimeRemaining
            || this.teef.burnTimeFresh != this.burnTimeFresh
            || this.teef.cookTime != this.cookTime)
        {
            int b = 0, c = 0;

            if (this.teef.burnTimeFresh != 0)
            {
                b = 100 * this.teef.burnTimeRemaining / this.teef.burnTimeFresh;
            }

            c = 100 * this.teef.cookTime / TileEntityEnderFurnace.COOKTIME_DEFAULT;

            // smelting progress and fuel burning progress are both 0..100, we send the smelting progress in the upper byte of the short
            listener.sendWindowProperty(this, 0, c << 8 | b);
        }

        if (this.teef.outputToEnderChest != this.outputToEnderChest)
        {
            listener.sendWindowProperty(this, 1, this.teef.outputToEnderChest ? 1 : 0);
        }

        this.burnTimeRemaining = this.teef.burnTimeRemaining;
        this.burnTimeFresh = this.teef.burnTimeFresh;
        this.cookTime = this.teef.cookTime;
        this.outputToEnderChest = this.teef.outputToEnderChest;
    }
}