本文整理匯總了Java中net.minecraft.inventory.IContainerListener類的典型用法代碼示例。如果您正苦於以下問題:Java IContainerListener類的具體用法?Java IContainerListener怎麽用?Java IContainerListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IContainerListener類屬於net.minecraft.inventory包,在下文中一共展示了IContainerListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
}
示例2: addListener
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
示例3: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
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);
}
示例4: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
}
示例5: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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]);
}
示例6: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
/**
* 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);
}
示例7: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
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);
}
}
}
示例8: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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;
}
示例9: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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;
}
示例10: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
示例11: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
示例12: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}
示例13: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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;
}
示例14: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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;
}
示例15: detectAndSendChanges
import net.minecraft.inventory.IContainerListener; //導入依賴的package包/類
@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);
}