use of logisticspipes.modules.ModuleActiveSupplier in project LogisticsPipes by RS485.
the class SlotFinderNumberPacket method processPacket.
@Override
@SuppressWarnings("unchecked")
public void processPacket(EntityPlayer player) {
IInventory inv = this.getTile(player.worldObj, IInventory.class);
if (inv instanceof ISidedInventory) {
inv = new SidedInventoryMinecraftAdapter((ISidedInventory) inv, ForgeDirection.UNKNOWN, false);
}
IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv);
Slot result = null;
if (((List<Slot>) player.openContainer.inventorySlots).get(inventorySlot).slotNumber == inventorySlot) {
result = ((List<Slot>) player.openContainer.inventorySlots).get(inventorySlot);
}
if (result == null) {
for (Slot slotObject : (List<Slot>) player.openContainer.inventorySlots) {
if (slotObject.slotNumber == inventorySlot) {
result = slotObject;
break;
}
}
}
if (result == null) {
player.addChatComponentMessage(new ChatComponentTranslation("lp.chat.slotnotfound"));
}
int resultIndex = -1;
if (resultIndex == -1) {
ItemStack content = result.getStack();
if (content != null) {
for (int i = 0; i < util.getSizeInventory(); i++) {
if (content == util.getStackInSlot(i)) {
resultIndex = i;
break;
}
}
} else {
ItemStack dummyStack = new ItemStack(Blocks.stone, 0, 0);
NBTTagCompound nbt = new NBTTagCompound();
//Make it unique
nbt.setBoolean("LPStackFinderBoolean", true);
dummyStack.setTagCompound(nbt);
result.putStack(dummyStack);
for (int i = 0; i < util.getSizeInventory(); i++) {
if (dummyStack == util.getStackInSlot(i)) {
resultIndex = i;
break;
}
}
if (resultIndex == -1) {
for (int i = 0; i < util.getSizeInventory(); i++) {
ItemStack stack = util.getStackInSlot(i);
if (stack == null) {
continue;
}
if (ItemIdentifier.get(stack).equals(ItemIdentifier.get(dummyStack)) && stack.stackSize == dummyStack.stackSize) {
resultIndex = i;
break;
}
}
}
result.putStack(null);
}
}
if (resultIndex == -1) {
player.addChatComponentMessage(new ChatComponentTranslation("lp.chat.slotnotfound"));
} else {
//Copy pipe to coordinates to use the getPipe method
setPosX(getPipePosX());
setPosY(getPipePosY());
setPosZ(getPipePosZ());
ModuleActiveSupplier module = this.getLogisticsModule(player, ModuleActiveSupplier.class);
if (module != null) {
module.slotArray[slot] = resultIndex;
}
}
}
use of logisticspipes.modules.ModuleActiveSupplier in project LogisticsPipes by RS485.
the class SupplierPipeLimitedPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
ModuleActiveSupplier module = this.getLogisticsModule(player, ModuleActiveSupplier.class);
if (module == null) {
return;
}
module.setLimited(isLimited());
if (MainProxy.isClient(player.worldObj)) {
refresh();
} else {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SupplierPipeLimitedPacket.class).setLimited(isLimited()).setPacketPos(this), player);
}
}
use of logisticspipes.modules.ModuleActiveSupplier in project LogisticsPipes by RS485.
the class SupplierPipeModePacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final ModuleActiveSupplier module = this.getLogisticsModule(player, ModuleActiveSupplier.class);
if (module == null) {
return;
}
int mode;
if (module.hasPatternUpgrade()) {
mode = module.getPatternMode().ordinal() + 1;
if (mode >= PatternMode.values().length) {
mode = 0;
}
module.setPatternMode(PatternMode.values()[mode]);
} else {
mode = module.getSupplyMode().ordinal() + 1;
if (mode >= SupplyMode.values().length) {
mode = 0;
}
module.setSupplyMode(SupplyMode.values()[mode]);
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SupplierPipeMode.class).setHasPatternUpgrade(module.hasPatternUpgrade()).setInteger(mode).setPacketPos(this), player);
}
use of logisticspipes.modules.ModuleActiveSupplier in project LogisticsPipes by RS485.
the class ActiveSupplierInHand method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
DummyContainer dummy = new DummyModuleContainer(player, getInvSlot());
if (!(((DummyModuleContainer) dummy).getModule() instanceof ModuleActiveSupplier)) {
return null;
}
((DummyModuleContainer) dummy).setInventory(((ModuleActiveSupplier) ((DummyModuleContainer) dummy).getModule()).getDummyInventory());
dummy.addNormalSlotsForPlayerInventory(8, 60);
//Pipe slots
for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
dummy.addDummySlot(pipeSlot, 8 + pipeSlot * 18, 18);
}
return dummy;
}
use of logisticspipes.modules.ModuleActiveSupplier in project LogisticsPipes by RS485.
the class ActiveSupplierSlot method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
ModuleActiveSupplier module = this.getLogisticsModule(player.getEntityWorld(), ModuleActiveSupplier.class);
if (module == null) {
return null;
}
DummyContainer dummy = new DummyContainer(player.inventory, module.getDummyInventory());
dummy.addNormalSlotsForPlayerInventory(18, 97);
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 3; column++) {
dummy.addDummySlot(column + row * 3, 72 + column * 18, 18 + row * 18);
}
}
return dummy;
}
Aggregations