Fixed items with meta not working + mass storage support

This commit is contained in:
70000hp 2024-07-10 13:38:45 -04:00
parent d4e9a5d010
commit 7f666ecaff
8 changed files with 31 additions and 17 deletions

View File

@ -10,11 +10,13 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class ContainerMassStorage extends Container { public class ContainerMassStorage extends ContainerBase {
private TileEntityMassStorage storage; private TileEntityMassStorage storage;
public ContainerMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage te) { public ContainerMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage te) {
super(invPlayer,te);
this.storage = te; this.storage = te;
this.storage.openInventory(); this.storage.openInventory();
@ -22,15 +24,7 @@ public class ContainerMassStorage extends Container {
this.addSlotToContainer(new SlotPattern(storage, 1, 61, 53)); this.addSlotToContainer(new SlotPattern(storage, 1, 61, 53));
this.addSlotToContainer(new SlotTakeOnly(storage, 2, 61, 89)); this.addSlotToContainer(new SlotTakeOnly(storage, 2, 61, 89));
for(int i = 0; i < 3; i++) { playerInv(invPlayer,8,139,197);
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 139 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 197));
}
} }
@Override @Override

View File

@ -351,7 +351,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }

View File

@ -4,6 +4,7 @@ import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerMassStorage; import com.hbm.inventory.container.ContainerMassStorage;
import com.hbm.inventory.gui.GUIMassStorage; import com.hbm.inventory.gui.GUIMassStorage;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.INBTPacketReceiver; import com.hbm.tileentity.INBTPacketReceiver;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -11,12 +12,13 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IControlReceiver { public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IFilterable {
private int stack = 0; private int stack = 0;
public boolean output = false; public boolean output = false;
@ -156,6 +158,11 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
nbt.setByte("redstone", (byte) redstone); nbt.setByte("redstone", (byte) redstone);
} }
@Override
public void nextMode(int i) {
}
@Override @Override
public void receiveControl(NBTTagCompound data) { public void receiveControl(NBTTagCompound data) {
if(data.hasKey("provide") && slots[1] != null) { if(data.hasKey("provide") && slots[1] != null) {
@ -185,6 +192,19 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
if(data.hasKey("toggle")) { if(data.hasKey("toggle")) {
this.output = !output; this.output = !output;
} }
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markDirty();
} }
@Override @Override

View File

@ -262,7 +262,7 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }

View File

@ -206,7 +206,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }

View File

@ -140,7 +140,7 @@ public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUI
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }

View File

@ -138,7 +138,7 @@ public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }

View File

@ -138,7 +138,7 @@ public class TileEntityRadioTorchCounter extends TileEntityMachineBase implement
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
setInventorySlotContents( setInventorySlotContents(
slot, slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), nbt.getInteger("meta"))); new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot); nextMode(slot);
markChanged(); markChanged();
} }