NPE in Refinery GUI

https://github.com/SirSengir/BuildCraft/issues/10
This commit is contained in:
psxlover 2012-05-26 20:54:03 +03:00
parent 03752e43d9
commit 031035bd7d

View file

@ -1,12 +1,11 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.factory;
import net.minecraft.src.EntityPlayer;
@ -22,22 +21,23 @@ import net.minecraft.src.buildcraft.core.network.PacketPayload;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
public class ContainerRefinery extends BuildCraftContainer {
TileRefinery refinery;
public ContainerRefinery(InventoryPlayer inventory, TileRefinery refinery) {
super (3);
super(3);
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 9; k1++) {
addSlot(new Slot(inventory, k1 + l * 9 + 9, 8 + k1 * 18,
123 + l * 18));
123 + l * 18));
}
}
for (int i1 = 0; i1 < 9; i1++)
for (int i1 = 0; i1 < 9; i1++) {
addSlot(new Slot(inventory, i1, 8 + i1 * 18, 181));
}
this.refinery = refinery;
}
@ -45,27 +45,29 @@ public class ContainerRefinery extends BuildCraftContainer {
public boolean canInteractWith(EntityPlayer entityplayer) {
return refinery.isUseableByPlayer(entityplayer);
}
/* SETTING AND GETTING FILTERS */
/**
* @param slot
* @param liquidId
* @param liquidMeta (for future use)
* @ param liquidId
param liquidMeta (for future use)
*/
public void setFilter(int slot, int liquidId, int liquidMeta) {
refinery.setFilter(slot, liquidId);
PacketPayload payload = new PacketPayload(3, 0, 0);
payload.intPayload[0] = slot;
payload.intPayload[1] = liquidId;
payload.intPayload[2] = liquidMeta;
CoreProxy.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload).getPacket());
if (APIProxy.isRemote()) {
PacketPayload payload = new PacketPayload(3, 0, 0);
payload.intPayload[0] = slot;
payload.intPayload[1] = liquidId;
payload.intPayload[2] = liquidMeta;
CoreProxy.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload).getPacket());
}
}
public ItemStack getFilter(int slot) {
int liquidId = refinery.getFilter(slot);
if(liquidId > 0)
if (liquidId > 0)
return new ItemStack(liquidId, 0, 0);
else
return null;
@ -79,9 +81,9 @@ public class ContainerRefinery extends BuildCraftContainer {
@Override
public void updateCraftingResults() {
super.updateCraftingResults();
for(int i = 0; i < crafters.size(); i++)
refinery.sendGUINetworkData(this, (ICrafting)crafters.get(i));
}
super.updateCraftingResults();
for (int i = 0; i < crafters.size(); i++) {
refinery.sendGUINetworkData(this, (ICrafting) crafters.get(i));
}
}
}