if (!world.isRemote)
{
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEntityMonitorStorageFluid)
{
TileEntityMonitorStorageFluid monitorTE = (TileEntityMonitorStorageFluid) te;
ItemStack currItem = player.getCurrentEquippedItem();
if (currItem != null)
{
if (!monitorTE.isMatrixed() && currItem.isItemEqual(Materials.matConversionMatrix))
{
monitorTE.setMatrixed();
currItem.stackSize -= 1;
if (currItem.stackSize <= 0)
currItem = null;
return true;
}
if (!monitorTE.isLocked())
{
if (currItem.getItem() instanceof IFluidContainerItem)
{
FluidStack fluid = ((IFluidContainerItem) currItem.getItem()).getFluid(currItem);
monitorTE.setFluid(fluid != null ? fluid.getFluid() : null);
} else if (FluidContainerRegistry.isFilledContainer(currItem))
{
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(currItem);
monitorTE.setFluid(fluid != null ? fluid.getFluid() : null);
} else if (FluidContainerRegistry.isEmptyContainer(currItem))
{
monitorTE.setFluid(null);
}
} else
{
if (monitorTE.isMatrixed())
{
ItemStack toAdd = monitorTE.fillContainer(currItem.copy());
if (toAdd != null)
{
ForgeDirection orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
dropBlockAsItem_do(world, x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ, toAdd);
currItem.stackSize -= 1;
if (currItem.stackSize <= 0)
currItem = null;
}
}
}
} else if (player.isSneaking())
{
if (!monitorTE.isLocked())
{
monitorTE.setLocked(true);
player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.Locked")));
} else
{
monitorTE.setLocked(false);
player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.Unlocked")));
}
} else if (!player.isSneaking() && !monitorTE.isLocked())
{
monitorTE.setFluid(null);
}
}
}
return true;
}