Java Code Examples for net.minecraft.inventory.IContainerListener#sendProgressBarUpdate()

The following examples show how to use net.minecraft.inventory.IContainerListener#sendProgressBarUpdate() . 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: 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 2
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 3
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 4
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 5
Source File: ContainerAdvSolar.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.sunIsVisible != this.tile.underSun) {
            listener.sendProgressBarUpdate(this, 0, this.tile.underSun ? 1 : 0);
        }
        if (this.hasLens != this.tile.hasLens) {
            listener.sendProgressBarUpdate(this, 1, this.tile.hasLens ? 1 : 0);
        }
    }

    this.sunIsVisible = this.tile.underSun;
    this.hasLens = this.tile.hasLens;
}
 
Example 6
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 7
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 8
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 9
Source File: ContainerCarbonizeFurnace.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 0, this.tile.progress);
    listener.sendProgressBarUpdate(this, 1, (int) this.tile.requireEnergy);
    listener.sendProgressBarUpdate(this, 2, (int) this.tile.energy);
}
 
Example 10
Source File: ContainerFluidKineticGenerator.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 0, this.tile.fluidTank.getFluidAmount());
    if (this.tile.fluidTank.getFluid() != null) {
        // TODO Improve
        listener.sendProgressBarUpdate(this, 1, FluidRegistry.getFluidID(this.tile.fluidTank.getFluid().getFluid()));
    }
}
 
Example 11
Source File: ContainerCookingPot.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 = (IContainerListener)this.listeners.get(i);

		for(int j = 0; j < firepit.getFieldCount(); j++)
		{
			if(fields.get(j) != this.firepit.getField(j))
			{
				icontainerlistener.sendProgressBarUpdate(this, j, this.firepit.getField(j));
			}
		}
	}

	for(int j = 0; j < firepit.getFieldCount(); j++)
	{
		if(fields.get(j) != this.firepit.getField(j))
		{
			fields.set(j, this.firepit.getField(j));
		}
	}
}
 
Example 12
Source File: ContainerFirepit.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 = (IContainerListener)this.listeners.get(i);

		for(int j = 0; j < firepit.getFieldCount(); j++)
		{
			if(fields.get(j) != this.firepit.getField(j))
			{
				icontainerlistener.sendProgressBarUpdate(this, j, this.firepit.getField(j));
			}
		}
	}

	for(int j = 0; j < firepit.getFieldCount(); j++)
	{
		if(fields.get(j) != this.firepit.getField(j))
		{
			fields.set(j, this.firepit.getField(j));
		}
	}
}
 
Example 13
Source File: ContainerAdvSolar.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 0, this.sunIsVisible ? 1 : 0);
    listener.sendProgressBarUpdate(this, 1, this.hasLens ? 1 : 0);
}
 
Example 14
Source File: ContainerParallelSpaceSU.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 0, (int) this.tile.energy);
    listener.sendProgressBarUpdate(this, 1, this.tile.redstoneMode.ordinal());
}
 
Example 15
Source File: ContainerHeatDryer.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 1, lastProgress);
    listener.sendProgressBarUpdate(this, 2, (int) lastEnergy);
}
 
Example 16
Source File: ContainerEUStorage.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 0, (int) this.tile.energy);
    listener.sendProgressBarUpdate(this, 1, this.tile.redstoneMode.ordinal());
}
 
Example 17
Source File: ContainerPackager.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void addListener(IContainerListener listener) {
    super.addListener(listener);
    listener.sendProgressBarUpdate(this, 1, lastProgress);
    listener.sendProgressBarUpdate(this, 2, (int) lastEnergy);
}